amritsar commited on
Commit
00f6a88
·
verified ·
1 Parent(s): 297bb9b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -3,8 +3,8 @@ from transformers import Wav2Vec2Processor, Wav2Vec2BertForCTC
3
  import torch
4
  import librosa
5
 
6
- # Load the Punjabi ASR model and processor
7
- model_id = 'kdcyberdude/w2v-bert-punjabi'
8
  processor = Wav2Vec2Processor.from_pretrained(model_id)
9
  model = Wav2Vec2BertForCTC.from_pretrained(model_id)
10
 
@@ -12,7 +12,7 @@ def transcribe_audio(audio_file):
12
  try:
13
  # Load and preprocess the audio
14
  audio, rate = librosa.load(audio_file, sr=16000)
15
- chunk_size = 59 * rate # 59-second chunks
16
  transcription = []
17
 
18
  for i in range(0, len(audio), chunk_size):
@@ -29,8 +29,7 @@ def transcribe_audio(audio_file):
29
 
30
  return " ".join(transcription)
31
  except Exception as e:
32
- print(f"Error during transcription: {e}")
33
- return "An error occurred during transcription."
34
 
35
  # Gradio interface setup
36
  iface = gr.Interface(
 
3
  import torch
4
  import librosa
5
 
6
+ # Load the correct processor and model
7
+ model_id = "kdcyberdude/w2v-bert-punjabi"
8
  processor = Wav2Vec2Processor.from_pretrained(model_id)
9
  model = Wav2Vec2BertForCTC.from_pretrained(model_id)
10
 
 
12
  try:
13
  # Load and preprocess the audio
14
  audio, rate = librosa.load(audio_file, sr=16000)
15
+ chunk_size = 30 * rate # 30-second chunks
16
  transcription = []
17
 
18
  for i in range(0, len(audio), chunk_size):
 
29
 
30
  return " ".join(transcription)
31
  except Exception as e:
32
+ return f"Error: {str(e)}"
 
33
 
34
  # Gradio interface setup
35
  iface = gr.Interface(