Update app.py
Browse files
app.py
CHANGED
@@ -95,23 +95,14 @@ def transcribe_audio_chunks(chunks):
|
|
95 |
os.unlink(temp_audio_file.name)
|
96 |
return ' '.join(transcriptions)
|
97 |
|
98 |
-
def
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
def get_file_info(file_path):
|
108 |
-
try:
|
109 |
-
result = subprocess.run(['ffprobe', '-v', 'quiet', '-print_format', 'json', '-show_format', '-show_streams', file_path],
|
110 |
-
capture_output=True, text=True, check=True)
|
111 |
-
return json.loads(result.stdout)
|
112 |
-
except subprocess.CalledProcessError 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:
|
@@ -188,7 +179,7 @@ def process_media(file_path, is_url=False):
|
|
188 |
formatted_transcript = f"Speaker 1: {transcription}"
|
189 |
|
190 |
transcription_text = formatted_transcript
|
191 |
-
generated_file = io.BytesIO(transcription_text.encode())
|
192 |
logger.info("Transcription and diarization completed successfully")
|
193 |
return "Transcription and diarization completed successfully!", True
|
194 |
except Exception as e:
|
|
|
95 |
os.unlink(temp_audio_file.name)
|
96 |
return ' '.join(transcriptions)
|
97 |
|
98 |
+
def download_file(url):
|
99 |
+
local_filename = url.split('/')[-1]
|
100 |
+
with requests.get(url, stream=True) as r:
|
101 |
+
r.raise_for_status()
|
102 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=os.path.splitext(local_filename)[1]) as temp_file:
|
103 |
+
for chunk in r.iter_content(chunk_size=8192):
|
104 |
+
temp_file.write(chunk)
|
105 |
+
return temp_file.name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
|
107 |
def get_file_info(file_path):
|
108 |
try:
|
|
|
179 |
formatted_transcript = f"Speaker 1: {transcription}"
|
180 |
|
181 |
transcription_text = formatted_transcript
|
182 |
+
generated_file = io.BytesIO(transcription_text.encode())
|
183 |
logger.info("Transcription and diarization completed successfully")
|
184 |
return "Transcription and diarization completed successfully!", True
|
185 |
except Exception as e:
|