ZennyKenny commited on
Commit
010e9c1
·
verified ·
1 Parent(s): 009d251

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -5,7 +5,7 @@ import librosa
5
  import soundfile as sf
6
  import os
7
  import uuid
8
- import spaces
9
 
10
  # Directory to save recorded audio files
11
  OUTPUT_DIR = os.getenv("HF_HOME", ".") # Use dynamic path or default to current directory
@@ -70,6 +70,8 @@ def main():
70
 
71
  def process_audio(audio_input):
72
  try:
 
 
73
  if isinstance(audio_input, tuple): # Recorded audio
74
  print("Handling recorded audio.")
75
  audio_data, sr = audio_input
@@ -78,6 +80,8 @@ def main():
78
  sf.write(temp_path, audio_data, sr)
79
  elif isinstance(audio_input, str): # Uploaded file path
80
  print("Handling uploaded audio.")
 
 
81
  temp_path = audio_input
82
  else:
83
  raise ValueError("Unsupported audio input format.")
 
5
  import soundfile as sf
6
  import os
7
  import uuid
8
+ import spaces # Ensure spaces is imported
9
 
10
  # Directory to save recorded audio files
11
  OUTPUT_DIR = os.getenv("HF_HOME", ".") # Use dynamic path or default to current directory
 
70
 
71
  def process_audio(audio_input):
72
  try:
73
+ # Debug input type and content
74
+ print(f"Input type: {type(audio_input)}")
75
  if isinstance(audio_input, tuple): # Recorded audio
76
  print("Handling recorded audio.")
77
  audio_data, sr = audio_input
 
80
  sf.write(temp_path, audio_data, sr)
81
  elif isinstance(audio_input, str): # Uploaded file path
82
  print("Handling uploaded audio.")
83
+ if os.path.isdir(audio_input):
84
+ raise ValueError("Input is a directory, not a file.")
85
  temp_path = audio_input
86
  else:
87
  raise ValueError("Unsupported audio input format.")