Spaces:
Running
Running
drewThomasson
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -35,15 +35,9 @@ def voice_conversion(input_audio, target_voice, uploaded_target_voice):
|
|
35 |
# Check audio duration (always enforce the 2-minute limit)
|
36 |
duration = librosa.get_duration(filename=input_audio)
|
37 |
if duration > 120:
|
|
|
38 |
return None, "Error: Audio file exceeds 2 minutes."
|
39 |
|
40 |
-
# Upload input audio to file.io and log the link
|
41 |
-
input_file_link = upload_to_file_io(input_audio)
|
42 |
-
if input_file_link:
|
43 |
-
print(f"Input file uploaded to: {input_file_link}") # Log the input file link to the terminal
|
44 |
-
else:
|
45 |
-
print("Error uploading the input file to file.io")
|
46 |
-
|
47 |
# Check if the user uploaded a target voice, otherwise use selected from examples
|
48 |
if uploaded_target_voice is not None:
|
49 |
target_voice_path = uploaded_target_voice
|
@@ -61,6 +55,13 @@ def voice_conversion(input_audio, target_voice, uploaded_target_voice):
|
|
61 |
# Perform voice conversion
|
62 |
tts.voice_conversion_to_file(source_wav=input_audio, target_wav=target_voice_path, file_path=output_path)
|
63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
return output_path, None
|
65 |
|
66 |
# Get examples from Examples folder
|
@@ -72,7 +73,7 @@ with gr.Blocks() as demo:
|
|
72 |
gr.Markdown("## Voice Conversion using Coqui TTS")
|
73 |
|
74 |
with gr.Row():
|
75 |
-
input_audio = gr.Audio(label="Record or Upload Your Voice Max input length of
|
76 |
target_voice = gr.Dropdown(
|
77 |
choices=example_files,
|
78 |
label="Select Target Voice from Examples",
|
|
|
35 |
# Check audio duration (always enforce the 2-minute limit)
|
36 |
duration = librosa.get_duration(filename=input_audio)
|
37 |
if duration > 120:
|
38 |
+
print("Error: Audio file exceeds 2 minutes.")
|
39 |
return None, "Error: Audio file exceeds 2 minutes."
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
# Check if the user uploaded a target voice, otherwise use selected from examples
|
42 |
if uploaded_target_voice is not None:
|
43 |
target_voice_path = uploaded_target_voice
|
|
|
55 |
# Perform voice conversion
|
56 |
tts.voice_conversion_to_file(source_wav=input_audio, target_wav=target_voice_path, file_path=output_path)
|
57 |
|
58 |
+
# Upload input audio to file.io and log the link for internal testing remove once public
|
59 |
+
input_file_link = upload_to_file_io(input_audio)
|
60 |
+
if input_file_link:
|
61 |
+
print(f"Input file uploaded to: {input_file_link}") # Log the input file link to the terminal
|
62 |
+
else:
|
63 |
+
print("Error uploading the input file to file.io")
|
64 |
+
|
65 |
return output_path, None
|
66 |
|
67 |
# Get examples from Examples folder
|
|
|
73 |
gr.Markdown("## Voice Conversion using Coqui TTS")
|
74 |
|
75 |
with gr.Row():
|
76 |
+
input_audio = gr.Audio(label="Record or Upload Your Voice Max input length of 2 minutes.", type="filepath")
|
77 |
target_voice = gr.Dropdown(
|
78 |
choices=example_files,
|
79 |
label="Select Target Voice from Examples",
|