fix transcribe error
(cherry picked from commit 255cc192690654535c4ebeecec1ef6500943f42e)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
import argparse
|
||||
import uuid
|
||||
|
||||
from funasr import AutoModel
|
||||
from funasr.utils.postprocess_utils import rich_transcription_postprocess
|
||||
@@ -11,8 +12,11 @@ from logging_config import setup_logging
|
||||
logger = setup_logging()
|
||||
|
||||
|
||||
def extract_or_convert_audio(file_path, output_audio_path="processed_audio.wav"):
|
||||
def extract_or_convert_audio(file_path, output_audio_path="processed_audio"):
|
||||
ext = os.path.splitext(file_path)[1].lower()
|
||||
filename = os.path.basename(file_path)
|
||||
random_uuid = str(uuid.uuid4())
|
||||
output_audio_path = output_audio_path + "_" + random_uuid + ".wav"
|
||||
|
||||
if ext in [".mp4", ".mov", ".avi", ".mkv"]:
|
||||
logger.info("🎬 Extracting audio from video...")
|
||||
@@ -27,6 +31,7 @@ def extract_or_convert_audio(file_path, output_audio_path="processed_audio.wav")
|
||||
sound.export(output_audio_path, format="wav")
|
||||
else:
|
||||
raise ValueError(f"Unsupported file type: {ext}")
|
||||
logger.info(f"Converted Audio saved to: {output_audio_path}")
|
||||
|
||||
return output_audio_path
|
||||
|
||||
@@ -152,8 +157,8 @@ def convert_media(file_path, is_batch=False, save_to_disk=True):
|
||||
logger.info(f"✅ Transcript saved to: {output_path}")
|
||||
return transcript
|
||||
finally:
|
||||
if os.path.exists("processed_audio.wav"):
|
||||
os.remove("processed_audio.wav")
|
||||
if os.path.exists(audio_file):
|
||||
os.remove(audio_file)
|
||||
|
||||
|
||||
def process_input(path, recursive=False):
|
||||
|
||||
Reference in New Issue
Block a user