Kishorekumar7 commited on
Commit
0239fd9
·
verified ·
1 Parent(s): 35f2be4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -8
app.py CHANGED
@@ -18,6 +18,10 @@ image_pipeline.to(device)
18
 
19
  # --- Step 1: Transcribe Tamil Audio using Groq's whisper-large-v3 ---
20
  def transcribe_tamil_audio(audio):
 
 
 
 
21
  filename = "temp_audio.m4a"
22
 
23
  try:
@@ -27,14 +31,18 @@ def transcribe_tamil_audio(audio):
27
  print("Audio loading error:", str(e))
28
  return "⚠️ Failed to process audio. Please try uploading a different file."
29
 
30
- with open(filename, "rb") as file:
31
- transcription = client.audio.transcriptions.create(
32
- file=(filename, file.read()),
33
- model="whisper-large-v3",
34
- language="ta",
35
- response_format="verbose_json",
36
- )
37
- return transcription.text
 
 
 
 
38
 
39
  # --- Step 2: Translate using gemma2-9b-it ---
40
  def translate_tamil_to_english(tamil_text):
 
18
 
19
  # --- Step 1: Transcribe Tamil Audio using Groq's whisper-large-v3 ---
20
  def transcribe_tamil_audio(audio):
21
+ if not audio or not os.path.exists(audio):
22
+ print("Audio path is invalid or file does not exist.")
23
+ return "⚠️ Failed to process audio. Please try uploading a different file."
24
+
25
  filename = "temp_audio.m4a"
26
 
27
  try:
 
31
  print("Audio loading error:", str(e))
32
  return "⚠️ Failed to process audio. Please try uploading a different file."
33
 
34
+ try:
35
+ with open(filename, "rb") as file:
36
+ transcription = client.audio.transcriptions.create(
37
+ file=(filename, file.read()),
38
+ model="whisper-large-v3",
39
+ language="ta",
40
+ response_format="verbose_json",
41
+ )
42
+ return transcription.text
43
+ except Exception as e:
44
+ print("Transcription error:", str(e))
45
+ return "⚠️ Failed to transcribe audio."
46
 
47
  # --- Step 2: Translate using gemma2-9b-it ---
48
  def translate_tamil_to_english(tamil_text):