Update app.py
Browse files
app.py
CHANGED
|
@@ -113,6 +113,15 @@ def get_file_info(file_path):
|
|
| 113 |
logger.error(f"Error getting file info: {str(e)}")
|
| 114 |
return None
|
| 115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
def process_media(file_path, is_url=False):
|
| 117 |
global generated_file, transcription_text
|
| 118 |
temp_file = None
|
|
@@ -152,10 +161,10 @@ def process_media(file_path, is_url=False):
|
|
| 152 |
try:
|
| 153 |
if is_video:
|
| 154 |
# Extract audio from video
|
| 155 |
-
cmd = ['ffmpeg', '-i', temp_file, '-vn', '-acodec', 'pcm_s16le', '-ar', '44100', '-ac', '2', wav_path, '-v', 'verbose']
|
| 156 |
elif is_audio:
|
| 157 |
# Convert audio to WAV
|
| 158 |
-
cmd = ['ffmpeg', '-i', temp_file, '-acodec', 'pcm_s16le', '-ar', '44100', '-ac', '2', wav_path, '-v', 'verbose']
|
| 159 |
else:
|
| 160 |
return "Unsupported file type: Neither audio nor video detected", False
|
| 161 |
|
|
@@ -179,7 +188,7 @@ def process_media(file_path, is_url=False):
|
|
| 179 |
formatted_transcript = f"Speaker 1: {transcription}"
|
| 180 |
|
| 181 |
transcription_text = formatted_transcript
|
| 182 |
-
generated_file = io.
|
| 183 |
logger.info("Transcription and diarization completed successfully")
|
| 184 |
return "Transcription and diarization completed successfully!", True
|
| 185 |
except Exception as e:
|
|
|
|
| 113 |
logger.error(f"Error getting file info: {str(e)}")
|
| 114 |
return None
|
| 115 |
|
| 116 |
+
def get_file_info(file_path):
|
| 117 |
+
try:
|
| 118 |
+
result = subprocess.run(['ffprobe', '-v', 'quiet', '-print_format', 'json', '-show_format', '-show_streams', file_path],
|
| 119 |
+
capture_output=True, text=True, check=True)
|
| 120 |
+
return json.loads(result.stdout)
|
| 121 |
+
except subprocess.CalledProcessError as e:
|
| 122 |
+
logger.error(f"Error getting file info: {str(e)}")
|
| 123 |
+
return None
|
| 124 |
+
|
| 125 |
def process_media(file_path, is_url=False):
|
| 126 |
global generated_file, transcription_text
|
| 127 |
temp_file = None
|
|
|
|
| 161 |
try:
|
| 162 |
if is_video:
|
| 163 |
# Extract audio from video
|
| 164 |
+
cmd = ['ffmpeg', '-y', '-i', temp_file, '-vn', '-acodec', 'pcm_s16le', '-ar', '44100', '-ac', '2', wav_path, '-v', 'verbose']
|
| 165 |
elif is_audio:
|
| 166 |
# Convert audio to WAV
|
| 167 |
+
cmd = ['ffmpeg', '-y', '-i', temp_file, '-acodec', 'pcm_s16le', '-ar', '44100', '-ac', '2', wav_path, '-v', 'verbose']
|
| 168 |
else:
|
| 169 |
return "Unsupported file type: Neither audio nor video detected", False
|
| 170 |
|
|
|
|
| 188 |
formatted_transcript = f"Speaker 1: {transcription}"
|
| 189 |
|
| 190 |
transcription_text = formatted_transcript
|
| 191 |
+
generated_file = io.BytsIO(transcription_text.encode())
|
| 192 |
logger.info("Transcription and diarization completed successfully")
|
| 193 |
return "Transcription and diarization completed successfully!", True
|
| 194 |
except Exception as e:
|