Nusri7 commited on
Commit
456232f
·
1 Parent(s): 8998902

Initial commit with FastAPI + Gradio app

Browse files
Files changed (1) hide show
  1. app.py +17 -3
app.py CHANGED
@@ -34,9 +34,23 @@ def get_similarity(audio1, audio2, sample_rate=16000):
34
  # API function to compare voices
35
  def compare_voices(file1, file2):
36
  try:
37
- # Gradio Audio returns a tuple of (audio, sample_rate)
38
- audio1, _ = file1 # Audio1 is a tuple (numpy_array, sample_rate)
39
- audio2, _ = file2 # Audio2 is a tuple (numpy_array, sample_rate)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
  # Get similarity score
42
  score, is_same_user = get_similarity(audio1, audio2)
 
34
  # API function to compare voices
35
  def compare_voices(file1, file2):
36
  try:
37
+ # Debug: Print the file types
38
+ print(f"Received file1: {type(file1)}")
39
+ print(f"Received file2: {type(file2)}")
40
+
41
+ if not file1 or not file2:
42
+ return {"error": "One or both audio inputs are missing."}
43
+
44
+ # Ensure file1 and file2 are tuples (numpy_array, sample_rate)
45
+ if isinstance(file1, tuple) and len(file1) == 2:
46
+ audio1, _ = file1 # Audio1 is a tuple (numpy_array, sample_rate)
47
+ else:
48
+ return {"error": "Invalid format for the first audio input."}
49
+
50
+ if isinstance(file2, tuple) and len(file2) == 2:
51
+ audio2, _ = file2 # Audio2 is a tuple (numpy_array, sample_rate)
52
+ else:
53
+ return {"error": "Invalid format for the second audio input."}
54
 
55
  # Get similarity score
56
  score, is_same_user = get_similarity(audio1, audio2)