helvekami commited on
Commit
5f13772
·
1 Parent(s): 400fc00

Updated Gradio App

Browse files
Files changed (1) hide show
  1. app.py +6 -10
app.py CHANGED
@@ -28,17 +28,13 @@ def process_audio(audio):
28
  if audio_data is None or len(audio_data) == 0:
29
  return "Audio data is empty. Please try again with a valid audio file."
30
 
31
- # Ensure audio_data is a numpy array.
32
- audio_data = np.asarray(audio_data)
33
 
34
- # If audio data is multi-dimensional, squeeze to 1D.
35
  if audio_data.ndim > 1:
36
  audio_data = np.squeeze(audio_data)
37
 
38
- # Convert audio data to floating-point if it's not already.
39
- if not np.issubdtype(audio_data.dtype, np.floating):
40
- audio_data = audio_data.astype(np.float32)
41
-
42
  # Resample to 16000 Hz if necessary.
43
  if sample_rate != 16000:
44
  try:
@@ -69,12 +65,12 @@ def process_audio(audio):
69
  # Create the Gradio interface.
70
  iface = gr.Interface(
71
  fn=process_audio,
72
- inputs=gr.Audio(type="numpy"), # Using file upload for audio input.
73
  outputs="text",
74
  title="Sarvam AI Shuka Voice Demo",
75
  description="Upload an audio file and get a response using Sarvam AI's Shuka model."
76
  )
77
 
78
  if __name__ == "__main__":
79
- # Set share=True to create a public link and use a non-default port.
80
- iface.launch(share=True, server_port=7861)
 
28
  if audio_data is None or len(audio_data) == 0:
29
  return "Audio data is empty. Please try again with a valid audio file."
30
 
31
+ # Force conversion of audio data to a floating-point numpy array.
32
+ audio_data = np.array(audio_data, dtype=np.float32)
33
 
34
+ # If the audio data is multi-dimensional, squeeze it to 1D.
35
  if audio_data.ndim > 1:
36
  audio_data = np.squeeze(audio_data)
37
 
 
 
 
 
38
  # Resample to 16000 Hz if necessary.
39
  if sample_rate != 16000:
40
  try:
 
65
  # Create the Gradio interface.
66
  iface = gr.Interface(
67
  fn=process_audio,
68
+ inputs=gr.Audio(type="numpy"), # Use file upload for audio input.
69
  outputs="text",
70
  title="Sarvam AI Shuka Voice Demo",
71
  description="Upload an audio file and get a response using Sarvam AI's Shuka model."
72
  )
73
 
74
  if __name__ == "__main__":
75
+ # Launch the app with share=True to create a public link.
76
+ iface.launch(share=True)