ZennyKenny commited on
Commit
db3a36a
·
verified ·
1 Parent(s): 875dc71

handle oor tuple

Browse files
Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -17,11 +17,15 @@ def split_audio(audio_data, sr, chunk_duration=30):
17
  def transcribe_long_audio(audio_input, transcriber, chunk_duration=30):
18
  """Transcribe long audio by splitting into smaller chunks."""
19
  try:
 
 
20
  if isinstance(audio_input, tuple): # Recorded audio
 
21
  audio_data, sr = audio_input # Unpack raw audio data and sample rate
22
  temp_path = "recorded_audio.wav"
23
  sf.write(temp_path, audio_data, sr) # Save recorded audio as a temporary file
24
  elif isinstance(audio_input, str): # Uploaded file path
 
25
  temp_path = audio_input # Use the file path directly
26
  else:
27
  raise ValueError("Unsupported audio input format.")
@@ -40,6 +44,7 @@ def transcribe_long_audio(audio_input, transcriber, chunk_duration=30):
40
  os.remove(temp_path) # Remove the temporary recorded audio file
41
  return " ".join(transcriptions)
42
  except Exception as e:
 
43
  return f"Error processing audio: {e}"
44
 
45
  @spaces.GPU(duration=3)
@@ -59,6 +64,7 @@ def main():
59
  summary = summarizer(transcription, max_length=50, min_length=10, do_sample=False)[0]["summary_text"]
60
  return transcription, summary
61
  except Exception as e:
 
62
  return f"Error processing audio: {e}", ""
63
 
64
  with gr.Blocks() as interface:
 
17
  def transcribe_long_audio(audio_input, transcriber, chunk_duration=30):
18
  """Transcribe long audio by splitting into smaller chunks."""
19
  try:
20
+ # Debugging input type and format
21
+ print(f"Audio input type: {type(audio_input)}")
22
  if isinstance(audio_input, tuple): # Recorded audio
23
+ print("Processing recorded audio...")
24
  audio_data, sr = audio_input # Unpack raw audio data and sample rate
25
  temp_path = "recorded_audio.wav"
26
  sf.write(temp_path, audio_data, sr) # Save recorded audio as a temporary file
27
  elif isinstance(audio_input, str): # Uploaded file path
28
+ print("Processing uploaded audio...")
29
  temp_path = audio_input # Use the file path directly
30
  else:
31
  raise ValueError("Unsupported audio input format.")
 
44
  os.remove(temp_path) # Remove the temporary recorded audio file
45
  return " ".join(transcriptions)
46
  except Exception as e:
47
+ print(f"Error in transcribe_long_audio: {e}")
48
  return f"Error processing audio: {e}"
49
 
50
  @spaces.GPU(duration=3)
 
64
  summary = summarizer(transcription, max_length=50, min_length=10, do_sample=False)[0]["summary_text"]
65
  return transcription, summary
66
  except Exception as e:
67
+ print(f"Error in process_audio: {e}")
68
  return f"Error processing audio: {e}", ""
69
 
70
  with gr.Blocks() as interface: