theuserme commited on
Commit
71dcf2e
·
verified ·
1 Parent(s): 566a8f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -5
app.py CHANGED
@@ -18,14 +18,12 @@ def transcribe_audio(audio_path):
18
  return "❌ Please record or upload an audio file."
19
 
20
  try:
21
- # librosa.load automatically handles web formats, fixes the volume,
22
- # and converts it to the 16,000 Hz the AI needs in one line of code!
23
  y, sr = librosa.load(audio_path, sr=16000)
24
 
25
- # Process the audio through your AI
26
  inputs = processor(y, sampling_rate=16000, return_tensors="pt")
27
  with torch.no_grad():
28
- predicted_ids = model.generate(**inputs.input_features, max_new_tokens=225)
 
29
 
30
  transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]
31
  return transcription
@@ -39,7 +37,6 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
39
  gr.Markdown("Speak Twi into your microphone, or upload an audio file.")
40
 
41
  with gr.Row():
42
- # THE FIX: type="filepath" forces Gradio to save a secure temp file first
43
  audio_input = gr.Audio(sources=["microphone", "upload"], type="filepath", label="Audio Input")
44
 
45
  with gr.Row():
 
18
  return "❌ Please record or upload an audio file."
19
 
20
  try:
 
 
21
  y, sr = librosa.load(audio_path, sr=16000)
22
 
 
23
  inputs = processor(y, sampling_rate=16000, return_tensors="pt")
24
  with torch.no_grad():
25
+ # THE FIX: Removed the '**' so the Tensor is passed correctly
26
+ predicted_ids = model.generate(inputs.input_features, max_new_tokens=225)
27
 
28
  transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]
29
  return transcription
 
37
  gr.Markdown("Speak Twi into your microphone, or upload an audio file.")
38
 
39
  with gr.Row():
 
40
  audio_input = gr.Audio(sources=["microphone", "upload"], type="filepath", label="Audio Input")
41
 
42
  with gr.Row():