mirror of
https://github.com/open-webui/open-webui
synced 2025-04-29 02:32:34 +00:00
refac
This commit is contained in:
parent
f0efee5de4
commit
05aa9c6d9c
@ -68,7 +68,7 @@ from pydub import AudioSegment
|
||||
from pydub.utils import mediainfo
|
||||
|
||||
|
||||
def audio_needs_conversion(file_path):
|
||||
def get_audio_format(file_path):
|
||||
"""Check if the given file needs to be converted to a different format."""
|
||||
if not os.path.isfile(file_path):
|
||||
log.error(f"File not found: {file_path}")
|
||||
@ -500,14 +500,14 @@ def transcribe(request: Request, file_path):
|
||||
log.debug(data)
|
||||
return data
|
||||
elif request.app.state.config.STT_ENGINE == "openai":
|
||||
conversion_type = audio_needs_conversion(file_path)
|
||||
if conversion_type:
|
||||
os.rename(file_path, file_path.replace(".wav", f".{conversion_type}"))
|
||||
audio_format = get_audio_format(file_path)
|
||||
if audio_format:
|
||||
os.rename(file_path, file_path.replace(".wav", f".{audio_format}"))
|
||||
# Convert unsupported audio file to WAV format
|
||||
convert_audio_to_wav(
|
||||
file_path.replace(".wav", f".{conversion_type}"),
|
||||
file_path.replace(".wav", f".{audio_format}"),
|
||||
file_path,
|
||||
conversion_type,
|
||||
audio_format,
|
||||
)
|
||||
|
||||
r = None
|
||||
|
Loading…
Reference in New Issue
Block a user