TTS Default Enable

这个提交包含在:
binary-husky
2024-05-30 14:27:18 +00:00
父节点 beda56abb0
当前提交 80c4281888
共有 2 个文件被更改,包括 14 次插入10 次删除

查看文件

@@ -12,15 +12,16 @@ RUN echo '[global]' > /etc/pip.conf && \
echo 'trusted-host = mirrors.aliyun.com' >> /etc/pip.conf echo 'trusted-host = mirrors.aliyun.com' >> /etc/pip.conf
# 语音输出功能以下两行,第一行更换阿里源,第二行安装ffmpeg,都可以删除
RUN UBUNTU_VERSION=$(awk -F= '/^VERSION_CODENAME=/{print $2}' /etc/os-release); echo "deb https://mirrors.aliyun.com/debian/ $UBUNTU_VERSION main non-free contrib" > /etc/apt/sources.list; apt-get update
RUN apt-get install ffmpeg -y
# 进入工作路径(必要) # 进入工作路径(必要)
WORKDIR /gpt WORKDIR /gpt
# TTS相关功能 # 安装大部分依赖,利用Docker缓存加速以后的构建 (以下两行,可以删除)
RUN apt update && apt install ffmpeg -y
# 安装大部分依赖,利用Docker缓存加速以后的构建 (以下三行,可以删除)
COPY requirements.txt ./ COPY requirements.txt ./
RUN pip3 install -r requirements.txt RUN pip3 install -r requirements.txt

查看文件

@@ -160,11 +160,14 @@ def start_app(app_block, CONCURRENT_COUNT, AUTHENTICATION, PORT, SSL_KEYFILE, SS
temp_file_name = str(uuid.uuid4().hex) temp_file_name = str(uuid.uuid4().hex)
temp_file = os.path.join(temp_folder, f'{temp_file_name}.mp3') temp_file = os.path.join(temp_folder, f'{temp_file_name}.mp3')
await tts.save(temp_file) await tts.save(temp_file)
try:
mp3_audio = AudioSegment.from_file(temp_file, format="mp3") mp3_audio = AudioSegment.from_file(temp_file, format="mp3")
mp3_audio.export(temp_file, format="wav") mp3_audio.export(temp_file, format="wav")
with open(temp_file, 'rb') as wav_file: t = wav_file.read() with open(temp_file, 'rb') as wav_file: t = wav_file.read()
os.remove(temp_file) os.remove(temp_file)
return Response(content=t) return Response(content=t)
except:
raise RuntimeError("ffmpeg未安装,无法处理EdgeTTS音频。安装方法见`https://github.com/jiaaro/pydub#getting-ffmpeg-set-up`")
if TTS_TYPE == "LOCAL_SOVITS_API": if TTS_TYPE == "LOCAL_SOVITS_API":
# Forward the request to the target service # Forward the request to the target service
TARGET_URL = get_conf("GPT_SOVITS_URL") TARGET_URL = get_conf("GPT_SOVITS_URL")