老熟女激烈的高潮_日韩一级黄色录像_亚洲1区2区3区视频_精品少妇一区二区三区在线播放_国产欧美日产久久_午夜福利精品导航凹凸

重慶分公司,新征程啟航

為企業提供網站建設、域名注冊、服務器等服務

AzureCognitiveServices-Spee

Speech 服務是認知服務的一種,提供了語音轉文本,文本轉語音, 語音翻譯等,今天我們實戰的是語音轉文本(Speech To Text)。

創新互聯公司專注為客戶提供全方位的互聯網綜合服務,包含不限于成都做網站、成都網站制作、成都外貿網站建設、清徐網絡推廣、小程序定制開發、清徐網絡營銷、清徐企業策劃、清徐品牌公關、搜索引擎seo、人物專訪、企業宣傳片、企業代運營等,從售前售中售后,我們都將竭誠為您服務,您的肯定,是我們最大的嘉獎;創新互聯公司為所有大學生創業者提供清徐建站搭建服務,24小時服務熱線:028-86922220,官方網址:www.cdcxhl.com

STT支持兩種訪問方式,1.是SDK,2.是REST API。

其中:

SDK方式支持?識別麥克風的語音流 和 語音文件;

REST API方式僅支持語音文件;

準備工作:創建 認知服務之Speech服務:

Azure Cognitive Services- Speecdn.nlark.com/yuque/0/2020/png/741540/1580645460436-abeba30d-7098-41ba-a3bf-e932146333c1.png">

創建完成后,兩個重要的參數可以在頁面查看:

Azure Cognitive Services- Spee

一. REST API方式將語音文件轉換成文本:

Azure global的 Speech API 終結點請參考:

https://docs.microsoft.com/zh-cn/azure/cognitive-services/speech-service/rest-speech-to-text#regions-and-endpoints

Azure 中國區?的 Speech API 終結點:

截至到2020.2月,僅中國東部2區域已開通Speech服務,服務終結點為:

https://chinaeast2.stt.speech.azure.cn/speech/recognition/conversation/cognitiveservices/v1

對于Speech To Text來說,有兩種身份驗證方式:

其中Authorization? Token有效期為10分鐘。

Azure Cognitive Services- Spee

為了簡便,本文使用了Ocp-Apim-Subscription-Key的方式。

注意:如果要實現文本轉語音,按照上表,則必須使用 Authorization Token形式進行身份驗證。

構建請求的其他注意事項:

  1. 文件格式:

    Azure Cognitive Services- Spee

  2. 請求頭:

    Azure Cognitive Services- Spee
    需要注意的是,Key或者Authorization是二選一的關系。

  3. 請求參數:

    Azure Cognitive Services- Spee

在Postman中的示例如下:

Azure Cognitive Services- Spee

Azure Cognitive Services- Spee

Azure Cognitive Services- Spee

如果要在REST API中使用 Authorization Token,則需要先獲得Token:

Global 獲取Token的終結點:

https://docs.microsoft.com/zh-cn/azure/cognitive-services/speech-service/rest-speech-to-text#authentication

中國區獲取Token的終結點:

截至2020.02,只有中國東部2有Speech服務,其Token終結點為:

https://chinaeast2.api.cognitive.azure.cn/sts/v1.0/issuetoken

Postman獲取Token 參考如下:

Azure Cognitive Services- Spee

二. SDK方式將語音文件轉換成文本(Python示例):

在官網可以看到類似的代碼,但需要注意的是,該代碼僅在Azure Global的Speech服務中正常工作,針對中國區,需要做特定的修改(見下文)。

import azure.cognitiveservices.speech as speechsdk # Creates an instance of a speech config with specified subscription key and service region. # Replace with your own subscription key and service region (e.g., "chinaeast2"). speech_key, service_region = "YourSubscriptionKey", "YourServiceRegion" speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region) # Creates an audio configuration that points to an audio file. # Replace with your own audio filename. audio_filename = "whatstheweatherlike.wav" audio_input = speechsdk.AudioConfig(filename=audio_filename) # Creates a recognizer with the given settings speech_recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config, audio_config=audio_input) print("Recognizing first result...") # Starts speech recognition, and returns after a single utterance is recognized. The end of a # single utterance is determined by listening for silence at the end or until a maximum of 15 # seconds of audio is processed. ?The task returns the recognition text as result. # Note: Since recognize_once() returns only a single utterance, it is suitable only for single # shot recognition like command or query. # For long-running multi-utterance recognition, use start_continuous_recognition() instead. result = speech_recognizer.recognize_once() # Checks result. if result.reason == speechsdk.ResultReason.RecognizedSpeech: ? ?print("Recognized: {}".format(result.text)) elif result.reason == speechsdk.ResultReason.NoMatch: ? ?print("No speech could be recognized: {}".format(result.no_match_details)) elif result.reason == speechsdk.ResultReason.Canceled: ? ?cancellation_details = result.cancellation_details ? ?print("Speech Recognition canceled: {}".format(cancellation_details.reason)) ? ?if cancellation_details.reason == speechsdk.CancellationReason.Error: ? ? ? ?print("Error details: {}".format(cancellation_details.error_details))


代碼提供頁面:

https://docs.azure.cn/zh-cn/cognitive-services/speech-service/quickstarts/speech-to-text-from-file?tabs=linux&pivots=programming-language-python#create-a-python-application-that-uses-the-speech-sdk

針對中國區,需要使用自定義終結點的方式,才能正常使用SDK:

speech_key,?service_region?=?"Your?Key",?"chinaeast2"
template?=?"wss://{}.stt.speech.azure.cn/speech/recognition"?\
???????????????"/conversation/cognitiveservices/v1?initialSilenceTimeoutMs={:d}&language=zh-CN"
speech_config?=?speechsdk.SpeechConfig(subscription=speech_key,
endpoint=template.format(service_region,?int(initial_silence_timeout_ms)))

中國區完整代碼為:

#!/usr/bin/env?python
#?coding:?utf-8

#?Copyright?(c)?Microsoft.?All?rights?reserved.
#?Licensed?under?the?MIT?license.?See?LICENSE.md?file?in?the?project?root?for?full?license?information.
"""
Speech?recognition?samples?for?the?Microsoft?Cognitive?Services?Speech?SDK
"""

import?time
import?wave

try:
????import?azure.cognitiveservices.speech?as?speechsdk
except?ImportError:
????print("""
????Importing?the?Speech?SDK?for?Python?failed.
????Refer?to
????https://docs.microsoft.com/azure/cognitive-services/speech-service/quickstart-python?for
????installation?instructions.
????""")
????import?sys
????sys.exit(1)


#?Set?up?the?subscription?info?for?the?Speech?Service:
#?Replace?with?your?own?subscription?key?and?service?region?(e.g.,?"westus").
speech_key,?service_region?=?"your?key",?"chinaeast2"

#?Specify?the?path?to?an?audio?file?containing?speech?(mono?WAV?/?PCM?with?a?sampling?rate?of?16
#?kHz).
filename?=?"D:\FFOutput\speechtotext.wav"

def?speech_recognize_once_from_file_with_custom_endpoint_parameters():
????"""performs?one-shot?speech?recognition?with?input?from?an?audio?file,?specifying?an
????endpoint?with?custom?parameters"""
????initial_silence_timeout_ms?=?15?*?1e3
????template?=?"wss://{}.stt.speech.azure.cn/speech/recognition/conversation/cognitiveservices/v1?initialSilenceTimeoutMs={:d}&language=zh-CN"
????speech_config?=?speechsdk.SpeechConfig(subscription=speech_key,
????????????endpoint=template.format(service_region,?int(initial_silence_timeout_ms)))
????print("Using?endpoint",?speech_config.get_property(speechsdk.PropertyId.SpeechServiceConnection_Endpoint))
????audio_config?=?speechsdk.audio.AudioConfig(filename=filename)
????#?Creates?a?speech?recognizer?using?a?file?as?audio?input.
????#?The?default?language?is?"en-us".
????speech_recognizer?=?speechsdk.SpeechRecognizer(speech_config=speech_config,?audio_config=audio_config)
????
????result?=?speech_recognizer.recognize_once()

????#?Check?the?result
????if?result.reason?==?speechsdk.ResultReason.RecognizedSpeech:
????????print("Recognized:?{}".format(result.text))
????elif?result.reason?==?speechsdk.ResultReason.NoMatch:
????????print("No?speech?could?be?recognized:?{}".format(result.no_match_details))
????elif?result.reason?==?speechsdk.ResultReason.Canceled:
????????cancellation_details?=?result.cancellation_details
????????print("Speech?Recognition?canceled:?{}".format(cancellation_details.reason))
????????if?cancellation_details.reason?==?speechsdk.CancellationReason.Error:
????????????print("Error?details:?{}".format(cancellation_details.error_details))


speech_recognize_once_from_file_with_custom_endpoint_parameters()

需要注意的是,如果我們使用SDK識別麥克風中的語音,則將

speech_recognizer?=?speechsdk.SpeechRecognizer(speech_config=speech_config,?audio_config=audio_config)

修改為如下即可(去掉audio_config參數):

speech_recognizer?=?speechsdk.SpeechRecognizer(speech_config=speech_config)

公眾號鏈接:https://mp.weixin.qq.com/s/NA9kQsVDfzTXEqHMTdDExA

語雀地址:https://www.yuque.com/seanyu/azure/blwb5i


新聞名稱:AzureCognitiveServices-Spee
URL分享:http://www.xueling.net.cn/article/ijicds.html

其他資訊

在線咨詢
服務熱線
服務熱線:028-86922220
TOP
主站蜘蛛池模板: 精品麻豆剧传媒av国产九九九 | h纯肉无遮掩3d动漫免费网站 | 欧美最猛性bbbbxxxx | 漂亮人妇中出中文字幕在线 | 狠狠色狠狠色狠狠五月 | 业余自由性别成熟偷窥 | 久久久久久久成人 | 欧美在线v | 亚洲性av免费 | 超碰97在线看 | 亚洲最新免费视频 | 91?清视频免费?看 | 欧美18精品久久久无码午夜福利 | 日韩综合久久 | 钻石午夜影院 | 五月精品夜夜春夜夜爽久久 | 亚洲网中文字幕 | 日韩中文字幕视频 | 国产热99 | 午夜免费视频网站 | 又大又粗又硬又黄的免费视频 | 护士毛片| 97免费人做人爱在线看视频 | 中国亚洲女人69内射少妇 | 国产麻豆一精品一aV一免费软件 | h成年动漫在线看网站 | 日韩欧美一区二区三区不学 | 草莓视频色片 | 性生活一区| 成人天堂视频在线观看 | 最新日优天堂高清AV | 最新国产精品久久精品 | 亚洲成AV人片高潮喷水 | yell视频在线观看免费 | 国产美女在线一区 | 色网视频国产高清制服一区 | 少妇被粗大猛进进出出 | 久在线观看福利视频69 | 91爱在线?看| av天天色 | 99riav国产精品视频 |