Rehman1603 commited on
Commit
685f67f
·
verified ·
1 Parent(s): 2fe87f4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -9
app.py CHANGED
@@ -43,16 +43,11 @@ def process_media(media_id, access_token, phone_no_id, phone_no,business_id):
43
  def audio_transcribe(audio_path):
44
  try:
45
  # Load and preprocess audio
46
- audio, sampling_rate = librosa.load(audio_path, sr=16000)
47
- input_values = processor(audio, return_tensors="pt", sampling_rate=16000).input_values
 
48
 
49
- # Perform speech-to-text
50
- with torch.no_grad():
51
- logits = model(input_values).logits
52
- predicted_ids = torch.argmax(logits, dim=-1)
53
- transcription = processor.batch_decode(predicted_ids)[0]
54
-
55
- return transcription
56
  except Exception as e:
57
  return f"Error: {str(e)}"
58
 
 
43
  def audio_transcribe(audio_path):
44
  try:
45
  # Load and preprocess audio
46
+ aai.settings.api_key = "c3db74329eea4ff68b95888dca1e2d72"
47
+ transcriber = aai.Transcriber()
48
+ transcript = transcriber.transcribe(audio_path)
49
 
50
+ return transcript
 
 
 
 
 
 
51
  except Exception as e:
52
  return f"Error: {str(e)}"
53