You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure自定义语音模型部署报错:Invalid deploymentId问题排查求助

Azure自定义语音合成错误Code 1007(Invalid deploymentId)排查

问题详情

已在Azure Speech Studio完成自定义语音模型的训练、创建与部署,从部署页面获取了资源密钥、服务区域和Endpoint ID,且确认代码中已填入Endpoint ID,但运行代码时触发以下错误:

Error code: 1007. Error details: Invalid deploymentId XXXXX USP state: TurnStarted. Received audio size: 0 bytes.
CANCELED: Did you set the speech resource key and region values?

运行的C#代码如下:

using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.CognitiveServices.Speech;
using Microsoft.CognitiveServices.Speech.Audio;

class Program 
{
    // 示例要求环境变量名为"SPEECH_KEY"和"SPEECH_REGION"
    static string speechKey = "my-resource-key";
    static string speechRegion = "my-region";

    static void OutputSpeechSynthesisResult(SpeechSynthesisResult speechSynthesisResult, string text)
    {
        switch (speechSynthesisResult.Reason)
        {
            case ResultReason.SynthesizingAudioCompleted:
                Console.WriteLine($"语音合成完成");
                break;
            case ResultReason.Canceled:
                var cancellation = SpeechSynthesisCancellationDetails.FromResult(speechSynthesisResult);
                Console.WriteLine($"已取消: 原因={cancellation.Reason}");

                if (cancellation.Reason == CancellationReason.Error)
                {
                    Console.WriteLine($"已取消: 错误代码={cancellation.ErrorCode}");
                    Console.WriteLine($"已取消: 错误详情=[{cancellation.ErrorDetails}]");
                    Console.WriteLine($"已取消: 你是否设置了语音资源密钥和区域值?");
                }
                break;
            default:
                break;
        }
    }

    async static Task Main(string[] args)
    {
        var speechConfig = SpeechConfig.FromSubscription(speechKey, speechRegion);  

        // 发声的语音语言
        speechConfig.SpeechSynthesisVoiceName = "MyNeuralVoice"; 
        speechConfig.EndpointId = "my-endpoint-id"; 

        using (var speechSynthesizer = new SpeechSynthesizer(speechConfig))
        {
            // 从控制台获取文本并合成为默认扬声器输出
            Console.WriteLine("输入你想要合成的文本 >");
            string text = Console.ReadLine();

            var speechSynthesisResult = await speechSynthesizer.SpeakTextAsync(text);
            OutputSpeechSynthesisResult(speechSynthesisResult, text);
        }

        Console.WriteLine("按任意键退出...");
        Console.ReadKey();
    }
}

错误原因

  • Endpoint ID填写有误:错误提示明确指向无效的部署ID,可能是复制时带入了空格、特殊字符,或者误填了模型ID而非部署页面的Endpoint ID(部署ID是部署完成后生成的专属ID,和训练模型ID不同)。
  • 资源密钥/区域不匹配:系统无法通过当前密钥和区域验证部署ID的有效性,大概率是密钥对应的Azure语音资源与部署模型的资源不属于同一订阅,或者区域填写错误(比如部署在eastus2但代码写了eastus)。
  • 模型未完成部署:即使你认为部署完成,也可能存在后台部署未结束或部署失败的情况,需回到Speech Studio确认部署状态为"成功"。
  • 语音名称设置冲突:代码中手动指定了SpeechSynthesisVoiceName = "MyNeuralVoice",但自定义语音部署后,指定Endpoint ID时系统会自动关联对应的语音,手动设置通用语音名称会导致资源匹配失败。

解决方法

  1. 重新获取并粘贴Endpoint ID:前往Azure Speech Studio的部署页面,复制完整的Endpoint ID,确保无多余字符,直接替换代码中的my-endpoint-id。
  2. 验证密钥和区域一致性:确认speechKey和speechRegion与部署模型的语音资源完全一致,区域需与部署时选择的区域完全匹配。
  3. 检查部署状态:在Speech Studio中查看自定义语音的部署状态,确保状态为"已成功",若部署中则等待完成,若失败则重新部署。
  4. 移除或修正语音名称设置:删除speechConfig.SpeechSynthesisVoiceName = "MyNeuralVoice";这一行,或者替换为部署页面提供的自定义语音名称。指定Endpoint ID时无需额外设置语音名称,避免冲突。

内容的提问来源于stack exchange,提问作者deathloser

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 01:18:26