Spaces:
Running
on
Zero
Running
on
Zero
fix: Handle 'NamedString' object in file upload to prevent attribute error
Browse files
app.py
CHANGED
@@ -31,9 +31,16 @@ def process_uploaded_audio(file, state=True):
|
|
31 |
input_path = Path(INPUT_FOLDER) / "wav" / sanitized_filename
|
32 |
input_path.parent.mkdir(parents=True, exist_ok=True)
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
with open(input_path, 'wb') as f:
|
35 |
-
f.write(
|
36 |
-
|
37 |
return str(input_path)
|
38 |
|
39 |
def run_inference(model_type, config_path, start_check_point, input_dir, output_dir, device_ids="0"):
|
|
|
31 |
input_path = Path(INPUT_FOLDER) / "wav" / sanitized_filename
|
32 |
input_path.parent.mkdir(parents=True, exist_ok=True)
|
33 |
|
34 |
+
# Check if the file object has a `read` method, otherwise handle it differently.
|
35 |
+
if hasattr(file, 'read'):
|
36 |
+
file_content = file.read()
|
37 |
+
else:
|
38 |
+
# Assuming `file` is a NamedString or similar, with the content directly as a string
|
39 |
+
file_content = file.value # or file['value'] if it's a dictionary-like object
|
40 |
+
|
41 |
with open(input_path, 'wb') as f:
|
42 |
+
f.write(file_content)
|
43 |
+
|
44 |
return str(input_path)
|
45 |
|
46 |
def run_inference(model_type, config_path, start_check_point, input_dir, output_dir, device_ids="0"):
|