音声ファイルの作成
Windows用です。
Win32::OLEモジュールを使って、Microsoft Speech Platformを利用します。
use strict;
use warnings;
use Win32::OLE;
my $filename = 'test.wav';
my $speech = Win32::OLE->new('Speech.SpVoice')
or die "Microsoft Speech Platformが利用できません。";
my $stream = Win32::OLE->new("Speech.SpFileStream")
or die "Speech.SpFileStreamが利用できません。";
# SpeechAudioFormatType Enum
# http://msdn.microsoft.com/en-us/library/ms720595%28v=vs.85%29.aspx
$stream->{Format}->{Type} = 6;
$stream->Open($filename, 3, 0);
$speech->{Voice} = $speech->GetVoices->Item(0);
$speech->{AudioOutputStream} = $stream;
$speech->Speak('今日は暑いですね。');
$speech->WaitUntilDone(-1); # しゃべり終わるまで待つ
$stream->Close();
関連項目
・音声出力・音声一覧
