mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
fix: 处理opanai语音识别报错的问题
--bug=1046791 --user=刘瑞斌 【应用】使用 openai 语音输入模型、输出模型进行输入输出报错 https://www.tapd.cn/57709429/s/1582133
This commit is contained in:
parent
6d39cd8aff
commit
a2aab8df7e
|
|
@ -1,3 +1,5 @@
|
|||
import asyncio
|
||||
import io
|
||||
from typing import Dict
|
||||
|
||||
from openai import OpenAI
|
||||
|
|
@ -49,5 +51,9 @@ class OpenAISpeechToText(MaxKBBaseModel, BaseSpeechToText):
|
|||
base_url=self.api_base,
|
||||
api_key=self.api_key
|
||||
)
|
||||
res = client.audio.transcriptions.create(model=self.model, language="zh", file=audio_file)
|
||||
audio_data = audio_file.read()
|
||||
buffer = io.BytesIO(audio_data)
|
||||
buffer.name = "file.mp3" # this is the important line
|
||||
res = client.audio.transcriptions.create(model=self.model, language="zh", file=buffer)
|
||||
return res.text
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue