Macで音声合成できる


Terminal.appを起動させて下のコマンドを打ってみよう。

% say "Hello"


日本語はどうか。たとえば「こんにちは」。

% say "con itch wha"

いかにも英語圏の人のコンニイチワだ。


声も替えれる。

% say -v Princess "Hello"

Princess以外にもいろいろある。声のリストは
System Preferences -> Universal Access -> Open VoiceOver Utility -> Speech -> Default Voice
でみれる。


http://ja.doukaku.org/comment/4024/をみるとObjective-Cでも音声合成で遊べそう。
上記URLのコードそのままだけど、声のリストを表示させて、"Hello, world!"を言ってもらう。

#import <Foundation/Foundation.h>
#import <Appkit/Appkit.h>

int main(int argc, char** argv)
{
    NSAutoreleasePool* pool = [NSAutoreleasePool new];

    NSSpeechSynthesizer* s = [[[NSSpeechSynthesizer alloc] initWithVoice:@"com.apple.speech.synthesis.voice.Alex"] autorelease];
    
    NSLog(@"%@", [NSSpeechSynthesizer availableVoices]);
    [s startSpeakingString:@"Hello, world!"];
    while ([s isSpeaking]) ;
    [pool release];

    return 0;
}

コンパイルして実行。

% gcc -o main -framework Cocoa main.m
% ./main