增加加了博物馆展品清单数据库及对前端获取展品清单、展品详细的接口,增加了QWenOmni多模态大模型的支 持(主要为了测试),增加了本地部署大模型支持(主要为了测试,在autoDL上),修正了TTS生成和返回前端的逻辑与参数,增加了判断用户问题有没有在知识库中检索到相关片段、如果没有则直接返回并提示未包含
This commit is contained in:
@@ -133,7 +133,8 @@ class QwenTTS(Base):
|
||||
if parts[0] == 'cosyvoice-v1':
|
||||
self.is_cosyvoice = True
|
||||
self.voice = parts[1]
|
||||
def tts(self, text):
|
||||
# 参数stream_format 为产生的tts 音频数据格式, mp3 wav pcm
|
||||
def tts(self, text, sample_rate=8000,stream_format="mp3"):
|
||||
from dashscope.api_entities.dashscope_response import SpeechSynthesisResponse
|
||||
if self.is_cosyvoice is False:
|
||||
from dashscope.audio.tts import ResultCallback, SpeechSynthesizer, SpeechSynthesisResult
|
||||
@@ -143,7 +144,7 @@ class QwenTTS(Base):
|
||||
from dashscope.audio.tts_v2 import ResultCallback, SpeechSynthesizer, AudioFormat #, SpeechSynthesisResult
|
||||
from dashscope.audio.tts import SpeechSynthesisResult
|
||||
from collections import deque
|
||||
print(f"--QwenTTS--tts_stream begin-- {text}") # cyx
|
||||
# print(f"--QwenTTS--tts_stream begin-- {text}") # cyx
|
||||
class Callback(ResultCallback):
|
||||
def __init__(self) -> None:
|
||||
self.dque = deque()
|
||||
@@ -237,12 +238,52 @@ class QwenTTS(Base):
|
||||
format="mp3")
|
||||
else:
|
||||
self.callback = Callback_v2()
|
||||
print(f"--tts {sample_rate} {stream_format}")
|
||||
if sample_rate == 8000:
|
||||
if stream_format == 'mp3':
|
||||
format = AudioFormat.MP3_8000HZ_MONO_128KBPS
|
||||
elif stream_format == 'pcm':
|
||||
format = AudioFormat.PCM_8000HZ_MONO_16BIT
|
||||
elif stream_format == 'wav':
|
||||
format = AudioFormat.WAV_8000HZ_MONO_16BIT
|
||||
else:
|
||||
format = AudioFormat.MP3_8000HZ_MONO_128KBPS
|
||||
elif sample_rate == 16000:
|
||||
if stream_format == 'mp3':
|
||||
format = AudioFormat.MP3_16000HZ_MONO_128KBPS
|
||||
elif stream_format == 'pcm':
|
||||
format = AudioFormat.PCM_16000HZ_MONO_16BIT
|
||||
elif stream_format == 'wav':
|
||||
format = AudioFormat.WAV_16000HZ_MONO_16BIT
|
||||
else:
|
||||
format = AudioFormat.MP3_16000HZ_MONO_128KBPS
|
||||
elif sample_rate == 22050:
|
||||
if stream_format == 'mp3':
|
||||
format = AudioFormat.MP3_22050HZ_MONO_256KBPS
|
||||
elif stream_format == 'pcm':
|
||||
format = AudioFormat.PCM_22050HZ_MONO_16BIT
|
||||
elif stream_format == 'wav':
|
||||
format = AudioFormat.WAV_22050HZ_MONO_16BIT
|
||||
else:
|
||||
format = AudioFormat.MP3_22050HZ_MONO_256KBPS
|
||||
elif sample_rate == 44100:
|
||||
if stream_format == 'mp3':
|
||||
format = AudioFormat.MP3_44100HZ_MONO_256KBPS
|
||||
elif stream_format == 'pcm':
|
||||
format = AudioFormat.PCM_44100HZ_MONO_16BIT
|
||||
elif stream_format == 'wav':
|
||||
format = AudioFormat.WAV_44100HZ_MONO_16BIT
|
||||
else:
|
||||
format = AudioFormat.MP3_44100HZ_MONO_256KBPS
|
||||
# format=AudioFormat.MP3_44100HZ_MONO_256KBPS
|
||||
else:
|
||||
format = AudioFormat.MP3_44100HZ_MONO_256KBPS
|
||||
self.synthesizer = SpeechSynthesizer(
|
||||
model='cosyvoice-v1',
|
||||
# voice="longyuan", #"longfei",
|
||||
voice = self.voice,
|
||||
callback=self.callback,
|
||||
format=AudioFormat.MP3_44100HZ_MONO_256KBPS
|
||||
format=format
|
||||
)
|
||||
|
||||
self.synthesizer.call(text)
|
||||
|
||||
Reference in New Issue
Block a user