標籤:http os 使用 io strong ar for 檔案 div
想要多瞭解QtSpeech,那麼隨著本文的文字往下走吧!QtSpeech是一個Qt封裝的跨平台TTS(文本變成語音輸出)API,在不同平台下利用系統內建的TTS引擎。在Windows下使用SAPI, 在Mac下使用SpeechSynthesis,而在Linux下使用 Festival.
QtSpeech的官方項目首頁在: http://lynxline.com/projects/qtspeech
源碼git倉庫地址則在: http://gitorious.org/qt-speech
API的使用非常簡單,如果你是同步調用,發音結束後返回,可以使用QtSpeech::say
- <blockquote>#include <QtSpeech>
- …
- QtSpeech voice;
- voice.say(“Hello World!”);
如果是非同步呼叫(發音不會阻塞程式運行),則可以使用QtSpeech::tell
- <blockquote>#include <QtSpeech>
- …
- QtSpeech * voice = new QtSpeech(this);
- voice->tell(“Hello asynchronous world!”);
如果使用QtSpeech::tell,還可以加入slot函數,在發音結束時回調該slot
- voice->tell(“Hello!”, this, SLOT(onSpeechFinished()));
VoiceName可以用於設定發音類型的,比如英語或者法語,意大利語等
- QtSpeech::VoiceNames vs = QtSpeech::voices();
//不過,目前從原始碼來看只支援英語
在ubuntu下編譯
- $ #qtspeech 依賴的tts是festival,所以需要先安裝
- $ sudo apt-get install festival festival-dev
- $ sudo apt-get install libasound2-dev
- $ git clone git://gitorious.org/qt-speech/qt-speech.git
- $ cd qt-speech/
- $ qmake QtSpeech.pro
- $ make
- $ #test
目錄下有可以測試的例子,記得把音箱開啟
小結:QtSpeech就介紹到這裡吧,注意了,標頭檔得自己手動添加,如果還出錯的話,那就是你沒裝Qt開發包!!!不要飯低級錯誤哦。
QtSpeech, say “Hello World!”By admin | Published: February 10, 2011
I am glad to announce new small project that got first release – QtSpeech.
This is library providing Qt-like interface to system TTS (text-to-speech) engines to allow your application to say “Hello World!”.
Current API is very simple.
First you need to include <QtSpeech>. Then if your application just needed to say something synchronously (execution will wait in the point until speech is finished) you can use such code:
4 |
voice.say("Hello World!"); |
If you would like to do this in asynchronous way (so your application is not blocked meanwhile) just use tell() call:
1 |
QtSpeech * voice = new QtSpeech(this); |
2 |
voice->tell("Hello asynchronous world!"); |
If you need to invoke a slot at the end, use:
1 |
voice->tell("Hello!", this, SLOT(onSpeechFinished())); |
Also you have possibility to get list of voices and choose voice from available in your system:
1 |
QtSpeech::VoiceNames vs = QtSpeech::names() |
Current implementation support Windows using SAPI and Mac. I have plans to extend API to include more functionality but will try to choose what is common on all platforms.
Link to repository in Gitorius: http://gitorious.org/qt-speech
QtSpeech會讓Qt說話