shukdevdatta123 commited on
Commit
ea4087a
·
verified ·
1 Parent(s): 0ed3e8f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -32,8 +32,8 @@ def process_text_input(api_key, text_prompt, selected_voice):
32
  with open(temp_path, "wb") as f:
33
  f.write(wav_bytes)
34
 
35
- # Get the text response
36
- text_response = completion.choices[0].message.content
37
 
38
  return text_response, temp_path
39
  except Exception as e:
@@ -89,8 +89,8 @@ def process_audio_input(api_key, audio_path, text_prompt, selected_voice):
89
  with open(temp_path, "wb") as f:
90
  f.write(wav_bytes)
91
 
92
- # Get the text response
93
- text_response = completion.choices[0].message.content
94
 
95
  return text_response, temp_path
96
  except Exception as e:
@@ -118,9 +118,9 @@ def use_example_audio():
118
  return audio_path
119
 
120
  # Create Gradio Interface
121
- with gr.Blocks(title="OpenAI Audio Chat App") as app:
122
- gr.Markdown("# OpenAI Audio Chat App")
123
- gr.Markdown("Interact with GPT-4o audio model through text and audio inputs")
124
 
125
  # API Key input (used across all tabs)
126
  api_key = gr.Textbox(
@@ -219,7 +219,10 @@ with gr.Blocks(title="OpenAI Audio Chat App") as app:
219
  with open(temp_path, "wb") as f:
220
  f.write(wav_bytes)
221
 
222
- return f"Sample generated with voice: {voice_type}", temp_path
 
 
 
223
  except Exception as e:
224
  return f"Error: {str(e)}", None
225
 
 
32
  with open(temp_path, "wb") as f:
33
  f.write(wav_bytes)
34
 
35
+ # Get the text response - fix to retrieve text content properly
36
+ text_response = completion.choices[0].message.content[0].text
37
 
38
  return text_response, temp_path
39
  except Exception as e:
 
89
  with open(temp_path, "wb") as f:
90
  f.write(wav_bytes)
91
 
92
+ # Get the text response - fix to retrieve text content properly
93
+ text_response = completion.choices[0].message.content[0].text
94
 
95
  return text_response, temp_path
96
  except Exception as e:
 
118
  return audio_path
119
 
120
  # Create Gradio Interface
121
+ with gr.Blocks(title="VoxTalk") as app:
122
+ gr.Markdown("# VoxTalk")
123
+ gr.Markdown("*Voice-to-voice AI interaction platform*")
124
 
125
  # API Key input (used across all tabs)
126
  api_key = gr.Textbox(
 
219
  with open(temp_path, "wb") as f:
220
  f.write(wav_bytes)
221
 
222
+ # Fix to retrieve text content properly
223
+ text_response = completion.choices[0].message.content[0].text
224
+
225
+ return f"Sample: {text_response}", temp_path
226
  except Exception as e:
227
  return f"Error: {str(e)}", None
228