bluenevus commited on
Commit
bafe69e
·
verified ·
1 Parent(s): 05c54b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -18
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 get_file_info(file_path):
99
- try:
100
- result = subprocess.run(['ffprobe', '-v', 'quiet', '-print_format', 'json', '-show_format', '-show_streams', file_path],
101
- capture_output=True, text=True, check=True)
102
- return json.loads(result.stdout)
103
- except subprocess.CalledProcessError as e:
104
- logger.error(f"Error getting file info: {str(e)}")
105
- return None
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()) # Corrected from BytsIO to BytesIO
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: