2017-03-29 12 views
-1

テキストから音を得る方法はありますか?例えばサウンドシステムでテキストを再生するにはどうすればよいですか?

、我々は持っている:

let str = "Hello English" . 

は私がそのテキストからサウンドシステムを取得したいです。

+1

がAVSpeechSynthesizerに見て、AppCoda http://www.appcoda.com/text-to-speech-ios-tutorial/ – JustinM

+1

HTTPでのチュートリアルがあります://stackoverflow.com/questions/21623251/how-to-convert-string-to-audio-sound-file-in-ios-cocos2d およびhttp://stackoverflow.com/questions/13860091/ios-text-音声への変換 – Rivendell

+0

グーグル:playSound FUNC "スピーチへのテキスト" –

答えて

0

Ravy Chhengが答えたとおり、これは組み込みのAVFoundationライブラリを使用して基本的なtext-to speak関数を初期化します。詳細については、Appleがドキュメントをチェックアウト:https://developer.apple.com/reference/avfoundation/avspeechsynthesizer

import AVFoundation 

func playSound(str: String) { 
    let speechSynthesizer = AVSpeechSynthesizer() 
    let speechUtterance = AVSpeechUtterance(string: str) 
    speechSynthesizer.speak(speechUtterance) 
} 
関連する問題