镜像自地址
https://github.com/binary-husky/gpt_academic.git
已同步 2025-12-06 14:36:48 +00:00
TTS Default Enable
这个提交包含在:
11
Dockerfile
11
Dockerfile
@@ -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)
|
||||||
mp3_audio = AudioSegment.from_file(temp_file, format="mp3")
|
try:
|
||||||
mp3_audio.export(temp_file, format="wav")
|
mp3_audio = AudioSegment.from_file(temp_file, format="mp3")
|
||||||
with open(temp_file, 'rb') as wav_file: t = wav_file.read()
|
mp3_audio.export(temp_file, format="wav")
|
||||||
os.remove(temp_file)
|
with open(temp_file, 'rb') as wav_file: t = wav_file.read()
|
||||||
return Response(content=t)
|
os.remove(temp_file)
|
||||||
|
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")
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户