Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Text to-speech

216 views

Published on

Cocoa Study at Ikebukuro #4

Published in: Technology
  • Hello! I can recommend a site that has helped me. It's called ⇒ www.WritePaper.info ⇐ So make sure to check it out!
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

Text to-speech

  1. 1. Text-to-Speech Cocoa Study at Ikebukuro #4 Bitz Co., Ltd. 村上幸雄
  2. 2. Speech Synthesis
  3. 3. Cocoaでは NSSpeechSynthesizer *synthesizer = [[NSSpeechSynthesizer alloc] init]; [synthesizer setDelegate:self]; [synthesizer startSpeakingString:@"Hello, world."]; - (void)speehSynthesizer:(NSSpeechSynthesizer *)sender didFinishSpeaking:(BOOL)finishedpeaking { ... }
  4. 4. Core Foundationでは SpeechChannel *chan; err = NewSpeechChannel(NULL, &chan); CFNumber *callback = CFNumberCreate(NULL, kCFNumberLongType, HighlightSpoken err = SetSpeechProperty(chan, kSpeechWordCFCallBack, callback); err = SpeakCFString(chan, CFSTR("Hello, world."), NULL); void HighlightSpokenWord(SpeechChannel chan, SRefCo refCon, CFStringRef aString, CFRange wordRange) { .... }
  5. 5. AU Lab
  6. 6. Mastered for iTunes http://www.apple.com/jp/itunes/mastered-for-itunes/
  7. 7. テキストをsayコマンドで読み 上げる $ say -n : -f ./風琴と魚の町.txt
  8. 8. AU Labを起動
  9. 9. AUNetReceiveを追加
  10. 10. 接続
  11. 11. AUDistortionを選択
  12. 12. パラメータ調整
  13. 13. Text-to-Speech
  14. 14. SpeechSynthesis.h /*------------------------------------------*/ /* AudioUnit constants - new in 10.5 */ /*------------------------------------------*/ enum { kAudioUnitSubType_SpeechSynthesis = 'ttsp', /* kAudioUnitType_Generator */ kAudioUnitProperty_Voice = 3330, /* Get/Set (VoiceSpec) */ kAudioUnitProperty_SpeechChannel = 3331 /* Get (SpeechChannel) */ };
  15. 15. AUNodeinputNode, effectNode, outputNode; NewAUGraph(&_auGraph); AudioComponentDescription cd; cd.componentType = kAudioUnitType_Generator; cd.componentSubType = kAudioUnitSubType_SpeechSynthesis; cd.componentManufacturer = kAudioUnitManufacturer_Apple; cd.componentFlags = 0; cd.componentFlagsMask = 0; AUGraphAddNode(_auGraph, &cd, &inputNode); cd.componentType = kAudioUnitType_Effect; cd.componentSubType = kAudioUnitSubType_Delay; AUGraphAddNode(_auGraph, &cd, &effectNode); cd.componentType = kAudioUnitType_Output; cd.componentSubType = kAudioUnitSubType_DefaultOutput; AUGraphAddNode(_auGraph, &cd, &outputNode); AUGraphConnectNodeInput(_auGraph, inputNode, 0, effectNode, 0); AUGraphConnectNodeInput(_auGraph, effectNode, 0, outputNode, 0); AUGraphOpen(_auGraph); AUGraphInitialize(_auGraph); AudioUnit generateAudioUnit; AUGraphNodeInfo(_auGraph, inputNode, NULL, &generateAudioUnit); SpeechChannel channel; UInt32 sz = sizeof(SpeechChannel); AudioUnitGetProperty(generateAudioUnit, kAudioUnitProperty_SpeechChannel, kAudioUnitScope_Global, 0, &channel, &sz); AUGraphStart(_auGraph); SpeakCFString(channel, CFSTR("Hello, world."), NULL);
  16. 16. var inputNode: AUNode = 0 var effectNode: AUNode = 0 var outputNode: AUNode = 0 NewAUGraph(&auGraph); var cd = AudioComponentDescription() cd.componentType = kAudioUnitType_Generator cd.componentSubType = kAudioUnitSubType_SpeechSynthesis cd.componentManufacturer = kAudioUnitManufacturer_Apple cd.componentFlags = 0 cd.componentFlagsMask = 0 AUGraphAddNode(auGraph!, &cd, &inputNode) cd.componentType = kAudioUnitType_Effect cd.componentSubType = kAudioUnitSubType_Delay AUGraphAddNode(auGraph!, &cd, &effectNode) cd.componentType = kAudioUnitType_Output cd.componentSubType = kAudioUnitSubType_DefaultOutput AUGraphAddNode(auGraph!, &cd, &outputNode) AUGraphConnectNodeInput(auGraph!, inputNode, 0, effectNode, 0) AUGraphConnectNodeInput(auGraph!, effectNode, 0, outputNode, 0) AUGraphOpen(auGraph!) AUGraphInitialize(auGraph!) var generateAudioUnit: AudioUnit? = nil AUGraphNodeInfo(auGraph!, inputNode, nil, &generateAudioUnit) var channel: SpeechChannel? = nil var sz: UInt32 = UInt32(MemoryLayout<SpeechChannel>.size) AudioUnitGetProperty(generateAudioUnit!, kAudioUnitProperty_SpeechChannel, kAudioUnitScope_Global, 0, &channel, &sz) AUGraphStart(auGraph!) SpeakCFString(channel!, "Nice to meet you. It's nice to see you! Nice meeting you. I'm pleased to meet you. Please say hello to your family. I look forward to seeing you again. Yes. Let's get together soon." as NSString, nil)

×