zoukankan      html  css  js  c++  java
  • QtSpeech会让Qt说话

    想要多了解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!”

    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

  • 相关阅读:
    2955 ACM 杭电 抢银行 01背包 乘法
    杭店 ACM 1864 最大报销额 01背包
    【ACM】 1231 最大连续子序列
    如何保证消息队列的幂等性
    Kafka如何保证消息的高可用
    消息队列的优点和缺点
    架构学习和经验积累的方法
    如何撰写总体设计与详细设计文档
    如何做合格的面试官
    如何设计好的接口
  • 原文地址:https://www.cnblogs.com/lvdongjie/p/3944183.html
Copyright © 2011-2022 走看看