【问题标题】:Can I use the Azure Speech resource without an endpoint?我可以在没有终结点的情况下使用 Azure 语音资源吗?
【发布时间】:2021-10-01 02:31:39
【问题描述】:

我可以在没有终结点的情况下使用 Azure 语音资源吗?

我正在阅读微软教程。具体来说,我正在完成this 实验室。而在本实验中,语音资源的应用程序客户端不使用端点,它只使用密钥和位置。

文档中的here 也是如此:

To find the keys and location/region of a completed deployment, follow these steps:

1. Sign in to the Azure portal using your Microsoft account.

2. Select All resources, and select the name of your Cognitive Services resource.

3. On the left pane, under RESOURCE MANAGEMENT, select Keys and Endpoint.

Each subscription has two keys; you can use either key in your application. To copy/paste a key to your code editor or other location, select the copy button next to each key, switch windows to paste the clipboard contents to the desired location.

Additionally, copy the LOCATION value, which is your region ID (ex. westus, westeurope) for SDK calls.

如您所见,没有任何关于端点的信息。这意味着语音资源客户端将知道如何仅通过密钥和位置连接到语音资源。

我真的很困惑,因为我认为没有端点应该是不可能的。

例如here 使用语音资源的代码示例不使用任何端点(只有一个键和一个位置):

    import os
    from playsound import playsound
    from azure.cognitiveservices.speech import SpeechConfig, SpeechRecognizer, AudioConfig
    
    # Get spoken command from audio file
    file_name = 'light-on.wav'
    audio_file = os.path.join('data', 'speech', file_name)
    
    # Configure speech recognizer
    speech_config = SpeechConfig(cog_key, cog_location)
    audio_config = AudioConfig(filename=audio_file) # Use file instead of default (microphone)
    speech_recognizer = SpeechRecognizer(speech_config, audio_config)
    
    # Use a one-time, synchronous call to transcribe the speech
    speech = speech_recognizer.recognize_once()
    
    # Play the original audio file
    playsound(audio_file)
    
    # Show transcribed text from audio file
    print(speech.text)

我的意思是我什至无法想象语音资源客户端(由 Microsoft 实现)如何知道它应该连接到我的 Azure 门户中的资源,而不是连接到没有端点的其他门户中的资源。对我来说似乎是一种魔法,所以我肯定在这里遗漏了一些东西。

【问题讨论】:

    标签: azure speech-recognition azure-cognitive-services


    【解决方案1】:

    感谢您试用 Azure 语音服务。

    您说的完全正确 - 语音服务确实像任何其他此类云服务一样使用端点。

    如果您的代码使用Speech SDK,那么SDK 会根据您提供的信息(即位置)为您提供正确的端点。

    我从您的代码中看到,您正在尝试在线转录。 Here你会发现在这个场景中使用的所有区域端点。

    还有其他端点,例如 Speech-to-text REST API V3Text-to-speech。它们都在文档中进行了描述。

    【讨论】:

    • 所以,只是为了检查我的理解。这意味着库代码会将位置作为 URL 的一部分,所以只有位置是必需的,对吧?
    • 位置和资源键。是的,这就足够了。但是,请注意,这不是实例化 SpeechConfig 类的唯一方法。请参阅docs 了解所有可能的选项。
    猜你喜欢
    • 2013-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-03
    • 2012-08-04
    • 1970-01-01
    • 2017-12-31
    • 2019-01-31
    相关资源
    最近更新 更多