mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +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
|
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."""
|
"""Check if the given file needs to be converted to a different format."""
|
||||||
if not os.path.isfile(file_path):
|
if not os.path.isfile(file_path):
|
||||||
log.error(f"File not found: {file_path}")
|
log.error(f"File not found: {file_path}")
|
||||||
@ -500,14 +500,14 @@ def transcribe(request: Request, file_path):
|
|||||||
log.debug(data)
|
log.debug(data)
|
||||||
return data
|
return data
|
||||||
elif request.app.state.config.STT_ENGINE == "openai":
|
elif request.app.state.config.STT_ENGINE == "openai":
|
||||||
conversion_type = audio_needs_conversion(file_path)
|
audio_format = get_audio_format(file_path)
|
||||||
if conversion_type:
|
if audio_format:
|
||||||
os.rename(file_path, file_path.replace(".wav", f".{conversion_type}"))
|
os.rename(file_path, file_path.replace(".wav", f".{audio_format}"))
|
||||||
# Convert unsupported audio file to WAV format
|
# Convert unsupported audio file to WAV format
|
||||||
convert_audio_to_wav(
|
convert_audio_to_wav(
|
||||||
file_path.replace(".wav", f".{conversion_type}"),
|
file_path.replace(".wav", f".{audio_format}"),
|
||||||
file_path,
|
file_path,
|
||||||
conversion_type,
|
audio_format,
|
||||||
)
|
)
|
||||||
|
|
||||||
r = None
|
r = None
|
||||||
|
Loading…
Reference in New Issue
Block a user