challenge 音声合成でHello, world!

与えられた文字列を音声合成して再生する関数を作ってください。

使用したライブラリはタグでつけてください。またOSに依存する場合もタグでつけてください。日本語文字列も発音できることが好ましいですが、必須ではありません。

以下はサンプルです。

>>> say("Hello, world!")
>>> say("con nitch were") # 「こんにちは」
>>> say("daw cat coo org, sole what program mar know tum yen know Colosseum death")

Posted feedbacks - Objective-C

NSLog(@"%@", [NSSpeechSynthesizer availableVoices]);
で使える声の一覧を確認できます。
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#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];
  [s startSpeakingString:@"Hello, world!"];
  while ([s isSpeaking]) ;
  [s startSpeakingString:@"con nitch were"];
  while ([s isSpeaking]) ;
  [s startSpeakingString:@"daw cat coo org, sole what program mar know tum yen know Colosseum death"];
  while ([s isSpeaking]) ;
  
  [pool release];
  return 0;
}

Index

Feed

Other

Link

Pathtraq

loading...