yashgori20 commited on
Commit
2ad9a80
·
1 Parent(s): fcd8049

Fix audio transcription to use correct Groq API format

Browse files

- Changed to pass file contents instead of file object
- Using (filename, file_contents) tuple format per Groq documentation
- Added temperature=0.0 parameter for consistent results

Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -100,14 +100,15 @@ class ToolRegistry:
100
  if not any(filename.lower().endswith(ext) for ext in ['.wav', '.mp3', '.webm', '.m4a', '.ogg']):
101
  filename = 'audio.wav'
102
 
103
- # Create a tuple with (filename, file_object) for Groq API
104
- # This ensures Groq can properly detect the audio format
105
- file_tuple = (filename, audio_file)
106
 
107
  transcription = groq_client.audio.transcriptions.create(
108
- file=file_tuple,
109
  model="whisper-large-v3-turbo",
110
- response_format="text"
 
111
  )
112
  return str(transcription)
113
  except Exception as e:
 
100
  if not any(filename.lower().endswith(ext) for ext in ['.wav', '.mp3', '.webm', '.m4a', '.ogg']):
101
  filename = 'audio.wav'
102
 
103
+ # Read the file contents and create tuple as per Groq API documentation
104
+ # Format: (filename, file_contents)
105
+ file_contents = audio_file.read()
106
 
107
  transcription = groq_client.audio.transcriptions.create(
108
+ file=(filename, file_contents),
109
  model="whisper-large-v3-turbo",
110
+ response_format="text",
111
+ temperature=0.0
112
  )
113
  return str(transcription)
114
  except Exception as e: