MartialBE / one-hub

OpenAI 接口管理 & 分发系统,改自songquanpeng/one-api。支持更多模型,加入统计页面,完善非openai模型的函数调用。
https://one-hub.xiao5.info/
Apache License 2.0
1.16k stars 237 forks source link

Azure Speech转tts报错404 #164

Closed SuiYunsy closed 6 months ago

SuiYunsy commented 6 months ago

例行检查

问题描述

配置如下:

image image

调用方式:

from pathlib import Path
from openai import OpenAI
client = OpenAI(
    api_key="sk-oneapi令牌",
    base_url="https://oneapi地址/v1",
)

speech_file_path = Path(__file__).parent / "speech.mp3"
response = client.audio.speech.create(
  model="tts-1",
  voice="echo",
  input="跨云和混合环境部署 Windows 和 Linux 虚拟机,实现应用程序的现代化并开发应用。"
)

response.stream_to_file(speech_file_path)

调用程序后日志报错:

relay error (channel #2(AzTTS)): Provider API error: bad response status code 404 404 POST /v1/audio/speech

我用Azure官方的调用示例是正常的:

'''
  For more samples please visit https://github.com/Azure-Samples/cognitive-services-speech-sdk 
'''

import azure.cognitiveservices.speech as speechsdk

# Creates an instance of a speech config with specified subscription key and service region.
speech_key = "我的key"
service_region = "westeurope"

speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region)
# Note: the voice setting will not overwrite the voice element in input SSML.
speech_config.speech_synthesis_voice_name = "zh-CN-XiaochenMultilingualNeural"

text = "跨云和混合环境部署 Windows 和 Linux 虚拟机,实现应用程序的现代化并开发应用。"

# use the default speaker as audio output.
speech_synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config)

result = speech_synthesizer.speak_text_async(text).get()
# Check result
if result.reason == speechsdk.ResultReason.SynthesizingAudioCompleted:
    print("Speech synthesized for text [{}]".format(text))
elif result.reason == speechsdk.ResultReason.Canceled:
    cancellation_details = result.cancellation_details
    print("Speech synthesis canceled: {}".format(cancellation_details.reason))
    if cancellation_details.reason == speechsdk.CancellationReason.Error:
        print("Error details: {}".format(cancellation_details.error_details))

不知道还要补充哪些细节,希望作者大大可以看看是哪里的问题😂

MartialBE commented 6 months ago

你把https://westeurope.api.cognitive.microsoft.com/改成 https://westeurope.tts.speech.microsoft.com

这里确实有点误解。到时候我改简单点,只要输入地区,不需要输入完整的api地址。

SuiYunsy commented 6 months ago

好的,修改URL后就可以了,谢谢!

MartialBE commented 6 months ago

改了一下,之后只要输入地区就好了。 已在dev镜像更新

SuiYunsy commented 6 months ago

改了一下,之后只要输入地区就好了。 已在dev镜像更新

使用最新的v0.8.0版本,在windows本机本地新启动程序,尝试添加az speech,发现点不动提交😂 image image 这个提交按钮点不动,后台log也没反应。但是添加其他渠道是正常的。

MartialBE commented 6 months ago

emmm 忘记把url的必填给去除了。 已经修复