karthi311 commited on
Commit
14627c2
·
verified ·
1 Parent(s): 7ebedb1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -0
app.py CHANGED
@@ -55,13 +55,20 @@ def convert_mp4_to_mp3(mp4_path, mp3_path):
55
  # Transcribe audio
56
  def transcribe_audio(audio_path):
57
  try:
 
 
 
 
58
  inputs = ffmpeg_read(audio_path, whisper_pipeline.feature_extractor.sampling_rate)
59
  inputs = {"array": inputs, "sampling_rate": whisper_pipeline.feature_extractor.sampling_rate}
 
 
60
  result = whisper_pipeline(inputs, batch_size=BATCH_SIZE, return_timestamps=False)
61
  return result["text"]
62
  except Exception as e:
63
  return f"Error during transcription: {e}"
64
 
 
65
  # Classify the sentence to the correct SOAP section
66
  def classify_sentence(sentence):
67
  similarities = {section: util.pytorch_cos_sim(embedder.encode(sentence), soap_embeddings[section]) for section in soap_prompts.keys()}
 
55
  # Transcribe audio
56
  def transcribe_audio(audio_path):
57
  try:
58
+ if not os.path.exists(audio_path):
59
+ raise FileNotFoundError(f"Audio file not found: {audio_path}")
60
+
61
+ # Read the audio file and prepare inputs for Whisper
62
  inputs = ffmpeg_read(audio_path, whisper_pipeline.feature_extractor.sampling_rate)
63
  inputs = {"array": inputs, "sampling_rate": whisper_pipeline.feature_extractor.sampling_rate}
64
+
65
+ # Perform transcription using Whisper
66
  result = whisper_pipeline(inputs, batch_size=BATCH_SIZE, return_timestamps=False)
67
  return result["text"]
68
  except Exception as e:
69
  return f"Error during transcription: {e}"
70
 
71
+
72
  # Classify the sentence to the correct SOAP section
73
  def classify_sentence(sentence):
74
  similarities = {section: util.pytorch_cos_sim(embedder.encode(sentence), soap_embeddings[section]) for section in soap_prompts.keys()}