ParthBhuptani commited on
Commit
1932078
·
verified ·
1 Parent(s): bb8f2e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -74,9 +74,22 @@ def transcribe_audio(audio_path):
74
  print("Audio received:", audio_path)
75
 
76
  if audio_path is None:
77
- return "No audio received"
78
 
79
- return f"Audio file received: {audio_path}"
 
 
 
 
 
 
 
 
 
 
 
 
 
80
 
81
  # ── CSS ──────────────────────────────────────────────────────────────────────
82
  css = """
 
74
  print("Audio received:", audio_path)
75
 
76
  if audio_path is None:
77
+ return ""
78
 
79
+ try:
80
+ with open(audio_path, "rb") as audio_file:
81
+ result = speech_client.audio_to_text(audio_file)
82
+
83
+ print("Result:", result)
84
+
85
+ if hasattr(result, "text"):
86
+ return result.text
87
+
88
+ return str(result)
89
+
90
+ except Exception as e:
91
+ print("VOICE ERROR:", repr(e))
92
+ return f"Voice transcription failed: {repr(e)}"
93
 
94
  # ── CSS ──────────────────────────────────────────────────────────────────────
95
  css = """