QtSpeech會讓Qt說話

來源:互聯網
上載者:User

標籤: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

  1. <blockquote>#include <QtSpeech> 
  2. …  
  3. QtSpeech voice;  
  4. voice.say(“Hello World!”); 

如果是非同步呼叫(發音不會阻塞程式運行),則可以使用QtSpeech::tell

  1. <blockquote>#include <QtSpeech> 
  2. …  
  3. QtSpeech * voice = new QtSpeech(this);  
  4. voice->tell(“Hello asynchronous world!”);  

如果使用QtSpeech::tell,還可以加入slot函數,在發音結束時回調該slot

  1. voice->tell(“Hello!”, this, SLOT(onSpeechFinished()));  

VoiceName可以用於設定發音類型的,比如英語或者法語,意大利語等

  1. QtSpeech::VoiceNames vs = QtSpeech::voices(); 

//不過,目前從原始碼來看只支援英語

在ubuntu下編譯

  1. $ #qtspeech 依賴的tts是festival,所以需要先安裝  
  2. $ sudo apt-get install festival festival-dev  
  3. $ sudo apt-get install libasound2-dev  
  4. $ git clone git://gitorious.org/qt-speech/qt-speech.git  
  5. $ cd qt-speech/  
  6. $ qmake QtSpeech.pro  
  7. $ make  
  8. $ #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:

1 #include <QtSpeech>
2  
3 QtSpeech voice;
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說話

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.