'commit'
This commit is contained in:
@@ -42,10 +42,15 @@ async def save_audio(audio: UploadFile = File(...), txt: str = Form(...)):
|
||||
# 修改MP3保存路径为UPLOAD_DIR,使用相同文件名前缀
|
||||
mp3_file_name = os.path.splitext(file_name)[0] + ".mp3"
|
||||
mp3_file_path = os.path.join(UPLOAD_DIR, mp3_file_name)
|
||||
"""
|
||||
ffmpeg -i audio_00008a1143e64d75bd51e7b0c9e7ce2b.wav \
|
||||
-ar 16000 -ac 1 -acodec libmp3lame -b:a 64k \
|
||||
out_16k_16bit_mono.mp3
|
||||
"""
|
||||
try:
|
||||
# 使用ffmpeg将wav转换为mp3
|
||||
subprocess.run(
|
||||
["ffmpeg", "-i", temp_file, "-y", mp3_file_path],
|
||||
["ffmpeg", "-i", temp_file, "-ar", "16000", "-ac", "1", "-acodec", "libmp3lame", "-b:a", "128k", "-y", mp3_file_path],
|
||||
check=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user