Amamrnaf
commited on
Commit
·
4d59a71
1
Parent(s):
7d05777
interface
Browse files
app.py
CHANGED
|
@@ -1,7 +1,47 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
def
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import os
|
| 3 |
|
| 4 |
+
def process_input(text_input, speaker_audio, speaker_name, option_selected):
|
| 5 |
+
if speaker_audio is None or speaker_name.strip() == "":
|
| 6 |
+
return "Please provide a valid audio file and speaker name."
|
| 7 |
|
| 8 |
+
# Save speaker audio under the name of the speaker
|
| 9 |
+
speaker_audio_path = f"{speaker_name}.wav"
|
| 10 |
+
speaker_audio.save(speaker_audio_path)
|
| 11 |
+
|
| 12 |
+
# Placeholder for generating the output audio
|
| 13 |
+
output_audio_path = f"generated_{speaker_name}.wav"
|
| 14 |
+
|
| 15 |
+
# Assuming some TTS or cloning process here
|
| 16 |
+
# Generate and save the output audio
|
| 17 |
+
# Replace this with your actual processing logic
|
| 18 |
+
with open(output_audio_path, "wb") as f:
|
| 19 |
+
f.write(b"Placeholder audio data") # Replace with actual audio data
|
| 20 |
+
|
| 21 |
+
return output_audio_path
|
| 22 |
+
|
| 23 |
+
# Gradio interface
|
| 24 |
+
with gr.Blocks() as demo:
|
| 25 |
+
gr.Markdown("# Audio Cloning and Text-to-Speech")
|
| 26 |
+
|
| 27 |
+
with gr.Row():
|
| 28 |
+
text_input = gr.Textbox(label="Input Text", placeholder="Enter your text here.")
|
| 29 |
+
|
| 30 |
+
with gr.Row():
|
| 31 |
+
speaker_audio = gr.Audio(source="microphone", type="filepath", label="Speaker Audio (to be cloned)")
|
| 32 |
+
speaker_name = gr.Textbox(label="Speaker Name", placeholder="Enter the speaker's name.")
|
| 33 |
+
|
| 34 |
+
option_selected = gr.Dropdown(choices=["Option 1", "Option 2", "Option 3"], label="Select an Option")
|
| 35 |
+
|
| 36 |
+
submit_btn = gr.Button("Submit")
|
| 37 |
+
|
| 38 |
+
output_audio = gr.Audio(label="Generated Audio Output")
|
| 39 |
+
|
| 40 |
+
submit_btn.click(
|
| 41 |
+
process_input,
|
| 42 |
+
inputs=[text_input, speaker_audio, speaker_name, option_selected],
|
| 43 |
+
outputs=output_audio,
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
# Launch the Gradio app
|
| 47 |
demo.launch()
|