dindizz commited on
Commit
079e633
·
verified ·
1 Parent(s): 3ea5efb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -6
app.py CHANGED
@@ -6,19 +6,31 @@ import os
6
  openai.api_key = os.getenv('API_KEY')
7
 
8
  def transcribe_audio(file_path):
 
 
 
 
 
 
9
  # Open the wav file
10
- with open(file_path, 'rb') as audio_file:
11
- response = openai.Audio.transcriptions.create(
12
- model="whisper-1", # specify the appropriate model for transcription
13
- file=audio_file,
14
- language='ta' # specify 'ta' for Tamil language
15
- )
 
 
 
16
 
17
  # Extract the transcription text
18
  transcription_text = response['text']
19
  return transcription_text
20
 
21
  def transcribe_and_display(audio_path):
 
 
 
22
  # Transcribe the audio file
23
  transcription = transcribe_audio(audio_path)
24
  return transcription
 
6
  openai.api_key = os.getenv('API_KEY')
7
 
8
  def transcribe_audio(file_path):
9
+ if file_path is None:
10
+ return "Error: No file path provided."
11
+
12
+ # Debugging: Print the file path
13
+ print(f"Received file path: {file_path}")
14
+
15
  # Open the wav file
16
+ try:
17
+ with open(file_path, 'rb') as audio_file:
18
+ response = openai.Audio.transcriptions.create(
19
+ model="whisper-1", # specify the appropriate model for transcription
20
+ file=audio_file,
21
+ language='ta' # specify 'ta' for Tamil language
22
+ )
23
+ except Exception as e:
24
+ return f"Error during transcription: {e}"
25
 
26
  # Extract the transcription text
27
  transcription_text = response['text']
28
  return transcription_text
29
 
30
  def transcribe_and_display(audio_path):
31
+ # Debugging: Print the audio path
32
+ print(f"Received audio path: {audio_path}")
33
+
34
  # Transcribe the audio file
35
  transcription = transcribe_audio(audio_path)
36
  return transcription