AT&T Dev Prog:语音到文本自定义 Post

AT&T Dev Prog: Speech to Text Custom Post

当我查看 Developer.ATT.com 上的文档时,我看到了我应该使用的格式(代码)示例:

POST https://api.att.com/speech/v3/speechToTextCustom HTTP/1.1
Host: api.att.com
Authorization: Bearer 38C2399A23999
X-SpeechContext: GrammarList
Accept: application/json
Content-length: 7012
Content-Language: en-us
Content-type: multipart/x-srgs-audio; boundary=----------------------------46ef33c653e2

------------------------------46ef33c653e2
Content-Disposition: form-data; name="x-dictionary"; filename="speech_alpha.pls"
Content-Type: application/pls+xml

<?xml version="1.0" encoding="UTF-8"?>
<lexicon version="1.0" alphabet="sampa" xml:lang="en-US">
   <lexeme>
       <grapheme>Qiang</grapheme>
       <phoneme>tS { n</phoneme>
   </lexeme>
</lexicon>

------------------------------46ef33c653e2
Content-Disposition: form-data; name="x-grammar"
Content-Type: application/srgs+xml

<grammar root="top" xml:lang="en-US">
  <rule id="CONTACT">
      <one-of>
        <item>Qiang</item>
        <item>David</item>
      </one-of>
  </rule>
  <rule id="top" scope="public">
      <item>
          <one-of>
            <item>text</item>
            <item>send message to</item>
          </one-of>
      </item>
  <ruleref uri="#CONTACT"/>
  </rule>
</grammar>


------------------------------46ef33c653e2
Content-Disposition: form-data; name="x-voice"; filename="speech_ex.amr"
Content-Type: audio/amr

      {{...audio data...}}

------------------------------45ef33c653e2-- 

因为我无法让它工作,我想知道我是否应该也包括 post 的词典和语法部分?为什么?

要使用 customspeech 引擎(对于非标准语言),需要语法文件,因为无论何时使用 customspeech 引擎,您都需要提供用于转录的词汇。 您可以在没有语法文件的情况下使用常规语音 API 进行转录,但它可能无法涵盖您正在尝试做的事情。 看起来您正在尝试利用 AT&T customspeech 引擎提供的大量非英语语言。所有这些语言都需要您提供语法文件才能工作。 支持的非自定义语言是美式英语和美式西班牙语。