亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? codeproject audio_ostream - a text-to-speech ostream_ free source code and programming help.htm

?? linux 下的 簡單語音識別 代碼 可以參考下
?? HTM
?? 第 1 頁 / 共 5 頁
字號:
        <LI>A simple example of how to use <A 
        href="http://www.boost.org/libs/iostreams/doc/index.html">boost::iostreams</A> 
        </LI></UL>
      <H2>Background</H2>
      <P>I recently had to add audio outputs to a program (running on 
      Windows).</P>
      <P><A 
      href="http://www.microsoft.com/downloads/details.aspx?FamilyID=5e86ec97-40a7-453f-b0ee-6583171b4530&amp;DisplayLang=en">Microsoft's 
      SAPI SDK</A> provides a COM interface through which wide character strings 
      can be spoken via SAPI's TTS engine. The Code Project has many articles 
      explaining how to use SAPI to varying degrees of complexity. So why 
      another?</P>
      <P>Well, there were some additional features that I wanted that did not 
      exist in those articles.</P>
      <OL>
        <LI>As little or no COM hassle. Ideally, it should work within the 
        simplest Console application. 
        <LI>Full (transparent) support for types other than wide-char. e.g. 
        <CODE><SPAN class=code-keyword>char</SPAN>*</CODE>, <CODE>std::<SPAN 
        class=code-SDKkeyword>string</SPAN></CODE>s and even <CODE><SPAN 
        class=code-keyword>int</SPAN></CODE>s, <CODE><SPAN 
        class=code-keyword>float</SPAN></CODE>s, etc. 
        <LI>Intuitive (or at least familiar) syntax </LI></OL>
      <P>To achieve these goals I developed <CODE>audio_ostream</CODE>.</P>
      <P><CODE>audio_ostream</CODE> is a full-fledged <CODE>std::ostream</CODE> 
      which supports any type that has an <CODE><SPAN 
      class=code-keyword>operator</SPAN><SPAN 
      class=code-keyword>&lt;</SPAN><SPAN 
      class=code-keyword>&lt;</SPAN>()</CODE>.</P>
      <P>You can have as many <CODE>audio_ostream</CODE>s as you like all 
      working in parallel.</P>
      <P>To handle COM issues, I used the wonderful COMSTL library which takes 
      care of all the delicate and brittle COMplications, such as 
      (un-)initialization, resource (de-)allocation, reference counting etc.</P>
      <P><CODE>boost::iostreams</CODE> is used to provide the full 
      <CODE>std::ostream</CODE> support with very little effort writing 
      boilerplate code.</P>
      <P>Since both <CODE>boost::iostreams</CODE> and COMSTL are header only 
      libraries I decided to make my class header only too. The minor price of 
      this decision is that the SAPI headers will be included into any file that 
      uses <CODE>audio_ostream</CODE>.</P>
      <H2>Using the code</H2>
      <P>Using the code cannot be easier:</P><PRE lang=c++><SPAN class=code-preprocessor>#include</SPAN><SPAN class=code-preprocessor> <SPAN class=code-string>"</SPAN><SPAN class=code-string>audiostream.hpp"</SPAN>
</SPAN><SPAN class=code-keyword>using</SPAN> <SPAN class=code-keyword>namespace</SPAN> std;
<SPAN class=code-keyword>using</SPAN> <SPAN class=code-keyword>namespace</SPAN> audiostream;
<SPAN class=code-keyword>int</SPAN> main()
{
   audio_ostream aout;
   aout <SPAN class=code-keyword>&lt;</SPAN><SPAN class=code-keyword>&lt;</SPAN> <SPAN class=code-string>"</SPAN><SPAN class=code-string>Hello World!"</SPAN>  <SPAN class=code-keyword>&lt;</SPAN><SPAN class=code-keyword>&lt;</SPAN> endl;
   <SPAN class=code-comment>//</SPAN><SPAN class=code-comment> some more code...
</SPAN>   <SPAN class=code-keyword>return</SPAN> <SPAN class=code-digit>0</SPAN>;
}</PRE>
      <P>This little program will, obviously, say "Hello World!".</P>
      <P>The audio stream is asynchronous so the program will continue running 
      even while the text is being said (that's why the line <CODE><SPAN 
      class=code-comment>//</SPAN><SPAN class=code-comment> some more 
      code...</SPAN></CODE> is there, to allow it to finish speaking). This is 
      conceptually similar to how <CODE>std::ostream</CODE>s buffer results 
      until the internal buffer is full and only then the text is displayed.</P>
      <P>To use the class:</P>
      <OL>
        <LI><CODE><SPAN class=code-preprocessor>#include</SPAN><SPAN 
        class=code-preprocessor></SPAN></CODE> the <CODE>audiostream.hpp</CODE> 
        header file. 
        <LI>Create an instance of <CODE>audio_ostream</CODE> (or 
        <CODE>waudio_ostream</CODE>) 
        <LI>Use the stream as you would any <CODE>std::ostream</CODE>. </LI></OL>
      <P>That's really all you need to do to start using the class.</P>
      <H2>Pre-Requisites</H2>
      <P>For the code to compile and run you will need 3 libraries:</P>
      <OL>
        <LI>For the TTS engine, you will need to install the <A 
        href="http://www.microsoft.com/downloads/details.aspx?FamilyID=5e86ec97-40a7-453f-b0ee-6583171b4530&amp;DisplayLang=en">Microsoft 
        Speech SDK</A> (I used ver. 5.1). 
        <LI>For COMSTL you will need the <A 
        href="http://synesis.com.au/software/stlsoft/">STLSoft libraries</A> 
        (you'll need STLSoft version 1.9.1 beta 44, or later). 
        <LI>The <A href="http://boost.org/">Boost</A> Iostreams library. You can 
        download Boost <A 
        href="http://sourceforge.net/project/showfiles.php?group_id=7586">here</A>. 
        </LI></OL>
      <P>Set your compiler and linker paths accordingly (Boost and STLSOft are 
      header only).</P>
      <H2>Advanced Usage</H2>
      <P>It's possible to change the voice gender, speed, language and many more 
      parameters of the voice using the SAPI text-to-speech (TTS) XML tags.</P>
      <P>Just insert the relevant XML tags into the stream to affect change. The 
      complete list of possible XML tags can be found <A 
      href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/SAPI51sr/Whitepapers/WP_XML_TTS_Tutorial.asp">here</A>.</P>
      <P>For example:</P><PRE lang=xml>audio_ostream aout;
// Select a male voice.
aout <SPAN class=code-keyword>&lt;</SPAN><SPAN class=code-leadattribute>&lt;</SPAN> <SPAN class=code-attribute>"&lt;voice</SPAN> <SPAN class=code-attribute>required</SPAN><SPAN class=code-keyword>='</SPAN><SPAN class=code-keyword>Gender=Male'</SPAN><SPAN class=code-keyword>&gt;</SPAN>Hello World!" <SPAN class=code-keyword>&lt;</SPAN><SPAN class=code-leadattribute>&lt;</SPAN> <SPAN class=code-attribute>endl;</SPAN> 
<SPAN class=code-attribute>aout</SPAN> <SPAN class=code-attribute>&lt;&lt;</SPAN> <SPAN class=code-attribute>"Five</SPAN> <SPAN class=code-attribute>hundred</SPAN> <SPAN class=code-attribute>milliseconds</SPAN> <SPAN class=code-attribute>of</SPAN> <SPAN class=code-attribute>silence"</SPAN> <SPAN class=code-attribute>&lt;&lt;</SPAN> <SPAN class=code-attribute>flush</SPAN> <SPAN class=code-attribute>&lt;&lt;</SPAN> 
    <SPAN class=code-attribute>"&lt;silence</SPAN> <SPAN class=code-attribute>msec</SPAN><SPAN class=code-keyword>='</SPAN><SPAN class=code-keyword>500'</SPAN><SPAN class=code-keyword>/</SPAN><SPAN class=code-keyword>&gt;</SPAN> just occurred." <SPAN class=code-keyword>&lt;</SPAN><SPAN class=code-leadattribute>&lt;</SPAN> <SPAN class=code-attribute>endl;</SPAN>
</PRE>
      <P>For some reason, the XML tags must be the first items in the SAPI 
      spoken string, without any preceding text. <CODE>flush</CODE>ing the 
      stream before the tag, as in the example, facilitates this.</P>
      <P>You can also call <CODE>SetRate()</CODE> with values [-10,10] to 
      control the speed of the speech.</P>
      <H2>The Magic</H2>
      <H3>The Core Class</H3>
      <P>The heart of the code is the <CODE>audio_sink</CODE> class:</P><PRE lang=c++><SPAN class=code-keyword>template</SPAN> <SPAN class=code-keyword>&lt;</SPAN> <SPAN class=code-keyword>class</SPAN> SinkType <SPAN class=code-keyword>&gt;</SPAN>
<SPAN class=code-keyword>class</SPAN> audio_sink: <SPAN class=code-keyword>public</SPAN> SinkType
{
<SPAN class=code-keyword>public</SPAN>:
   audio_sink()
   {      
      <SPAN class=code-comment>//</SPAN><SPAN class=code-comment> Initialize the COM libraries
</SPAN>      <SPAN class=code-keyword>static</SPAN> comstl::com_initializer coinit;                         
      <SPAN class=code-comment>//</SPAN><SPAN class=code-comment> Get SAPI Speech COM object
</SPAN>      HRESULT hr;
      <SPAN class=code-keyword>if</SPAN>(FAILED(hr = comstl::co_create_instance(CLSID_SpVoice, _pVoice))) 
          <SPAN class=code-keyword>throw</SPAN> comstl::com_exception(
              <SPAN class=code-string>"</SPAN><SPAN class=code-string>Failed to create SpVoice COM instance"</SPAN>,hr); 
   } 
   
   <SPAN class=code-comment>//</SPAN><SPAN class=code-comment> speak a character string
</SPAN>   std::streamsize write(<SPAN class=code-keyword>const</SPAN> <SPAN class=code-keyword>char</SPAN>* s, std::streamsize n)
   {
      <SPAN class=code-comment>//</SPAN><SPAN class=code-comment> make a null terminated string.
</SPAN>      std::<SPAN class=code-SDKkeyword>string</SPAN> str(s,n);                        
      <SPAN class=code-comment>//</SPAN><SPAN class=code-comment> convert to wide character and call the actual speak method.
</SPAN>      <SPAN class=code-keyword>return</SPAN> write(winstl::a2w(str), str.size());  
   }
   
   <SPAN class=code-comment>//</SPAN><SPAN class=code-comment> speak a wide character string
</SPAN>   std::streamsize write(<SPAN class=code-keyword>const</SPAN> <SPAN class=code-keyword>wchar_t</SPAN>* s, std::streamsize n)
   {
      <SPAN class=code-comment>//</SPAN><SPAN class=code-comment> make a null terminated wstring.
</SPAN>      std::wstring str(s,n);                       
      <SPAN class=code-comment>//</SPAN><SPAN class=code-comment> The actual COM call to Speak.
</SPAN>      _pVoice-<SPAN class=code-keyword>&gt;</SPAN>Speak(str.c_str(), SPF_ASYNC, <SPAN class=code-digit>0</SPAN>);   
      <SPAN class=code-keyword>return</SPAN> n;
   }
   
   <SPAN class=code-comment>//</SPAN><SPAN class=code-comment> Set the speech speed.
</SPAN>   <SPAN class=code-keyword>void</SPAN> setRate(<SPAN class=code-keyword>long</SPAN> n) { _pVoice-<SPAN class=code-keyword>&gt;</SPAN>SetRate(n); }   

<SPAN class=code-keyword>private</SPAN>:      
   <SPAN class=code-comment>//</SPAN><SPAN class=code-comment> COM object smart pointer.
</SPAN>   stlsoft::ref_ptr<SPAN class=code-keyword>&lt;</SPAN> ISpVoice <SPAN class=code-keyword>&gt;</SPAN> _pVoice;             
};</PRE>
      <P>There's a lot going on in this little class. Let's tease apart the 
      pieces one-by-one.</P>
      <H3>COMSTL, stlsoft::ref_ptr&lt;&gt; and ISpVoice</H3>
      <P>The only member of the class is <CODE>stlsoft::ref_ptr<SPAN 
      class=code-keyword>&lt;</SPAN> ISpVoice <SPAN 
      class=code-keyword>&gt;</SPAN> _pVoice</CODE>.</P>
      <P>This is the smart pointer that will handle all the COM stuff for us. 
      The STLSoft class <A 
      hfer="http://www.synesis.com.au/software/stlsoft/doc-1.9/&#13;&#10;classstlsoft_1_1ref__ptr.html">stlsoft::ref_ptr&lt;&gt;</A> 
      provides RAII-safe handling of reference-counted interfaces (RCIs). 
      Specifically, it is ideal for handling COM objects.</P>
      <P>We are using it with the <CODE>ISpVoice</CODE> interface. From 
      Microsoft's <A 
      href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/SAPI51sr/html/ISpVoice.asp">site</A>:</P><EM>The 
      <CODE>ISpVoice</CODE> interface enables an application to perform text 
      synthesis operations. Applications can speak text strings and text files, 
      or play audio files through this interface. All of these can be done 
      synchronously or asynchronously.</EM> 
      <P>In the constructor, we first initialize COM usage via the 
      <CODE>comstl::com_initializer</CODE>. This only happens once (since it is 
      a static object), and should not trouble us anymore. To initialize 
      <CODE>_pVoice</CODE> we call <CODE>comstl::co_create_instance()</CODE> 
      with the <CODE>CLSID_SpVoice</CODE> ID. If all goes well, we are now 
      holding an <CODE>ISpVoice</CODE> object handle. All reference counting 
      issues will be handled by <CODE>stlsoft::ref_ptr<SPAN 
      class=code-keyword>&lt;</SPAN><SPAN class=code-keyword>&gt;</SPAN></CODE>. 
      If the call fails an <CODE>comstl::com_exception</CODE> exception is 
      thrown and the class instance will not be created.</P>
      <P>To speak some text we just need to call <CODE>_pVoice-<SPAN 
      class=code-keyword>&gt;</SPAN>Speak()</CODE> with a wide character 
      string.</P>
      <P>To "speak text" we just need to call <CODE>_pVoice-<SPAN 
      class=code-keyword>&gt;</SPAN>Speak()</CODE> with a wide character 
      string.</P>
      <P>However, we would like to support other character types like 
      <CODE><SPAN class=code-keyword>char</SPAN>*</CODE>, <CODE>std::<SPAN 
      class=code-SDKkeyword>string</SPAN></CODE> and more. In fact, we want to 
      support any type that can be converted to a string or wide-string via an 
      <CODE><SPAN class=code-keyword>operator</SPAN><SPAN 
      class=code-keyword>&lt;</SPAN><SPAN 
      class=code-keyword>&lt;</SPAN>()</CODE>.</P>
      <H3>Boost Iostreams </H3>
      <P><A 
      href="http://www.boost.org/libs/iostreams/doc/index.html">boost::iostreams</A> 
      makes it easy to create standard C++ streams and stream buffers for 
      accessing new Sources and Sinks. To rephrase from the <A 
      href="http://www.boost.org/libs/iostreams/doc/index.html">site</A>:</P>
      <P><EM>A Sink provides write-access to a sequence of characters of a given 
      type. A Sink may expose this sequence by defining a member function 
      <CODE>write</CODE>, invoked indirectly by the Iostreams library through 
      the function <CODE>boost::iostreams::write</CODE>.</EM></P>
      <P>There are 2 pre-defined sinks, <CODE>boost::iostreams::sink</CODE> and 
      <CODE>boost::iostreams::wsink</CODE> for writing narrow and wide string 
      respectively.</P>
      <P>To make our class a Sink and get all its functionality, all we have to 
      do is to derive our class from either of these classes (depending if we 
      want narrow and wide character output). Thus, <CODE>audio_sink</CODE> is a 
      template class that derives from its template parameter.</P>
      <P>To use our sink and create a concrete <CODE>ostream</CODE>, we need to 
      use the <CODE>boost::iostreams::stream</CODE> class.</P>
      <P>The supporting class is <CODE>audio_ostream_t</CODE>: </P><PRE lang=c++><SPAN class=code-keyword>template</SPAN> <SPAN class=code-keyword>&lt;</SPAN> <SPAN class=code-keyword>class</SPAN> SinkType <SPAN class=code-keyword>&gt;</SPAN>
<SPAN class=code-keyword>class</SPAN> audio_ostream_t: <SPAN class=code-keyword>public</SPAN> boost::iostreams::stream<SPAN class=code-keyword>&lt;</SPAN> SinkType <SPAN class=code-keyword>&gt;</SPAN>, 
<SPAN class=code-keyword>public</SPAN> SinkType
{
<SPAN class=code-keyword>public</SPAN>:
   audio_ostream_t()
   {
      <SPAN class=code-comment>//</SPAN><SPAN class=code-comment> Connect to Sink
</SPAN>      open(*<SPAN class=code-keyword>this</SPAN>);
   }
};
<SPAN class=code-keyword>typedef</SPAN> audio_ostream_t<SPAN class=code-keyword>&lt;</SPAN> audio_sink<SPAN class=code-keyword>&lt;</SPAN> boost::iostreams::sink  <SPAN class=code-keyword>&gt;</SPAN> <SPAN class=cod

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
丝袜脚交一区二区| 精品污污网站免费看| 在线免费观看视频一区| 欧美精品一区二区三区在线| 一区二区三区小说| 国产美女主播视频一区| 欧美日本精品一区二区三区| 亚洲国产精品成人综合色在线婷婷| 亚洲国产中文字幕在线视频综合| 国产福利精品一区| 日韩亚洲国产中文字幕欧美| 亚洲欧美视频一区| 国产91丝袜在线播放0| 日韩免费电影一区| 日一区二区三区| 色综合中文字幕| 中文字幕一区二区在线观看| 黑人巨大精品欧美一区| 欧美美女一区二区三区| 洋洋成人永久网站入口| 99久久精品国产精品久久| 国产日韩成人精品| 国产一区二区三区| www国产精品av| 六月丁香婷婷久久| 精品人在线二区三区| 蜜桃精品视频在线| 宅男在线国产精品| 日韩av在线播放中文字幕| 欧美日韩国产综合草草| 亚洲超碰精品一区二区| 欧美亚洲国产怡红院影院| 亚洲主播在线观看| 欧美亚洲日本国产| 天天免费综合色| 91精品婷婷国产综合久久性色| 肉色丝袜一区二区| 日韩欧美国产精品| 狠狠色综合色综合网络| 久久久久久久久久美女| 高清久久久久久| 国产精品久久久久久久久免费樱桃 | 久久精品一区二区三区av| 狠狠色综合播放一区二区| 亚洲精品一区二区在线观看| 国产成a人亚洲精品| 国产欧美日韩卡一| 色伊人久久综合中文字幕| 一区二区三国产精华液| 精品国产乱码久久久久久图片| 肉色丝袜一区二区| 久久综合丝袜日本网| 成人免费看片app下载| 亚洲欧洲美洲综合色网| 色狠狠一区二区三区香蕉| 日精品一区二区| 久久久久久久综合狠狠综合| 成人av午夜电影| 一二三四社区欧美黄| 欧美成人r级一区二区三区| 国产激情偷乱视频一区二区三区| 亚洲欧美欧美一区二区三区| 欧美一区二区三区男人的天堂| 国产一区二区导航在线播放| 一区二区三区四区在线播放| 欧美一级高清片在线观看| 国产999精品久久久久久绿帽| 一区二区三区中文免费| 欧美成人三级电影在线| av资源网一区| 乱一区二区av| 亚洲美女屁股眼交3| 日韩欧美久久久| 91免费观看视频| 麻豆国产精品官网| 亚洲黄网站在线观看| 日韩视频免费直播| 91丨九色丨黑人外教| 久久精品久久99精品久久| 亚洲欧美怡红院| 26uuu精品一区二区三区四区在线| 成人午夜视频福利| 日本不卡中文字幕| 亚洲人亚洲人成电影网站色| 欧美sm美女调教| 在线影视一区二区三区| 国产成人激情av| 蜜桃91丨九色丨蝌蚪91桃色| 亚洲精品视频在线观看网站| 国产色一区二区| 日韩欧美视频在线| 欧美日韩一级黄| 91日韩一区二区三区| 懂色av一区二区在线播放| 免费成人性网站| 天堂精品中文字幕在线| 亚洲精品国产一区二区三区四区在线| 久久嫩草精品久久久久| 欧美一区二区人人喊爽| 欧美在线|欧美| 一本大道久久a久久综合婷婷| 国产精品综合网| 精品在线亚洲视频| 青娱乐精品视频| 日日欢夜夜爽一区| 日韩精品1区2区3区| 一区二区三区成人| 亚洲综合色在线| 一区二区三区日韩精品视频| 亚洲美女视频在线观看| 亚洲欧美偷拍三级| 一区二区三区欧美日韩| 亚洲男人天堂一区| 亚洲精品一卡二卡| 一区二区在线电影| 亚洲最新在线观看| 亚洲国产精品久久不卡毛片| 亚洲精品中文字幕乱码三区| 亚洲女爱视频在线| 亚洲综合丝袜美腿| 亚洲bdsm女犯bdsm网站| 午夜成人免费电影| 日本欧美大码aⅴ在线播放| 日本中文在线一区| 久久99精品久久久久| 国产一区在线不卡| 国产乱国产乱300精品| 国产高清精品在线| 99精品视频在线免费观看| 91国偷自产一区二区开放时间| 欧洲中文字幕精品| 日韩欧美中文字幕一区| 久久久久国产精品麻豆ai换脸| 久久久久国色av免费看影院| 国产精品成人免费在线| 亚洲综合精品自拍| 日本亚洲最大的色成网站www| 久久精品国产成人一区二区三区| 久久国产视频网| 不卡影院免费观看| 欧美日本一区二区三区四区| 亚洲精品在线免费播放| 1024成人网| 免费精品视频在线| 国产成人高清在线| 欧美少妇bbb| 久久久久久一二三区| 亚洲三级在线观看| 日本不卡视频在线观看| 成人av网站在线观看| 在线亚洲一区二区| 精品成人私密视频| 亚洲乱码国产乱码精品精的特点 | 色噜噜夜夜夜综合网| 欧美日韩mp4| 国产亚洲综合av| 亚洲.国产.中文慕字在线| 国产一区二区电影| 欧美日韩黄色一区二区| 国产精品欧美一区二区三区| 亚洲h精品动漫在线观看| 粉嫩av一区二区三区| 538在线一区二区精品国产| 国产精品无圣光一区二区| 日韩中文字幕1| 99精品欧美一区二区三区小说 | 色偷偷成人一区二区三区91| 91精品国产综合久久精品麻豆| 国产欧美日韩综合精品一区二区| 一区二区欧美在线观看| 国产a级毛片一区| 日韩欧美久久一区| 亚洲成在线观看| 91在线国产福利| 国产亚洲综合在线| 精品亚洲欧美一区| 88在线观看91蜜桃国自产| 最新欧美精品一区二区三区| 久久av老司机精品网站导航| 欧美日韩一区二区三区在线看| 国产精品高潮呻吟久久| 国产一区二区在线免费观看| 91精品国产一区二区三区香蕉| 亚洲精品日产精品乱码不卡| 成人免费福利片| 国产视频一区二区在线观看| 久久超级碰视频| 日韩欧美自拍偷拍| 免费观看成人鲁鲁鲁鲁鲁视频| 精品视频1区2区3区| 亚洲精品视频观看| 一本色道久久综合亚洲精品按摩| 国产精品日韩成人| 国产·精品毛片| 日本一区二区在线不卡| 国产一区在线视频| 久久众筹精品私拍模特| 国产毛片精品视频| 久久精品一区四区| 粉嫩aⅴ一区二区三区四区|