ZennyKenny commited on
Commit
b98ca5e
·
verified ·
1 Parent(s): d07525d

implement output

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
2
  import torch
3
  from transformers import pipeline
4
  import librosa
 
5
  import spaces
6
 
7
  def split_audio(audio_path, chunk_duration=30):
@@ -17,9 +18,9 @@ def transcribe_long_audio(audio_path, transcriber, chunk_duration=30):
17
  """Transcribe long audio by splitting into smaller chunks."""
18
  chunks, sr = split_audio(audio_path, chunk_duration)
19
  transcriptions = []
20
- for chunk in chunks:
21
- temp_path = "temp_chunk.wav"
22
- librosa.output.write_wav(temp_path, chunk, sr)
23
  transcription = transcriber(temp_path)["text"]
24
  transcriptions.append(transcription)
25
  return " ".join(transcriptions)
 
2
  import torch
3
  from transformers import pipeline
4
  import librosa
5
+ import soundfile as sf
6
  import spaces
7
 
8
  def split_audio(audio_path, chunk_duration=30):
 
18
  """Transcribe long audio by splitting into smaller chunks."""
19
  chunks, sr = split_audio(audio_path, chunk_duration)
20
  transcriptions = []
21
+ for i, chunk in enumerate(chunks):
22
+ temp_path = f"temp_chunk_{i}.wav"
23
+ sf.write(temp_path, chunk, sr) # Save the chunk using soundfile
24
  transcription = transcriber(temp_path)["text"]
25
  transcriptions.append(transcription)
26
  return " ".join(transcriptions)