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

使用Azure批量转录API遇swagger_client无CustomSpeechTranscriptionsApi属性错误

解决思路:AttributeError: module 'swagger_client' has no attribute 'CustomSpeechTranscriptionsApi'

核心原因

从你打印的dir(swagger_client)输出能看到,当前版本的swagger_client已移除CustomSpeechTranscriptionsApi类,取而代之的是DefaultApi——这是Speech Service的Swagger客户端生成逻辑更新后,API类结构调整导致的变化。

具体解决步骤

  • 替换API类引用:把代码第142行的swagger_client.CustomSpeechTranscriptionsApi直接替换为swagger_client.DefaultApi,示例修改如下:
    原代码:

    api = swagger_client.CustomSpeechTranscriptionsApi(api_client)
    

    修改后:

    api = swagger_client.DefaultApi(api_client)
    
  • 验证方法兼容性:执行print(dir(swagger_client.DefaultApi))查看该类的所有方法,原CustomSpeechTranscriptionsApi中批量转录相关的操作(如创建、查询转录任务)已迁移到DefaultApi中,方法名通常为create_transcription、get_transcription、list_transcriptions等,按需调整调用逻辑即可。

  • 重新生成匹配的Swagger客户端:若方法调用仍不兼容,建议直接基于Azure Speech to Text v3.0的官方规范重新生成客户端,确保客户端版本与API服务版本完全匹配。

  • 切换到示例仓库兼容版本:如果不想修改代码,可切换到Azure Speech SDK示例仓库中仍使用CustomSpeechTranscriptionsApi的历史提交版本,同时安装对应版本的依赖包,保持环境一致性。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.23 01:02:21