Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import numpy as np | |
| from robot_voice.change_to_robot_voice import RobotVoice | |
| from config_folder.config import run_config | |
| def convert_to_robot_voice(audio_path, VB, VL, H, LOOKUP_SAMPLES, MOD_F): | |
| # Run Config | |
| # _, _, _, _, VB, VL, H, LOOKUP_SAMPLES, MOD_F, _, _ = run_config() | |
| # Create Robot Voice Object | |
| rv_obj = RobotVoice(vb=VB, vl=VL, h=H, lookup_samples=LOOKUP_SAMPLES, mod_f=MOD_F) | |
| # Run | |
| robot_voice_arr, sr = rv_obj.run(input_func=audio_path, output_func=None, use_record=False, save_to_file=False) | |
| return sr, robot_voice_arr | |
| demo = gr.Blocks() | |
| with demo: | |
| gr.Markdown( | |
| """ | |
| # Human voice to Robot Voice | |
| - This project is based on the paper "A Simple Digital Model of the Diode-Based Ring-Modulator," which can be found at http://recherche.ircam.fr/pub/dafx11/Papers/66_e.pdf. | |
| - This project builds upon the excellent work of [Neil Lakin/robot_voice](https://github.com/nrlakin/robot_voice) on his **robot_voice** project. Please follow my GitHub repository - [Voice-Human2Robot](https://github.com/danhtran8mind/voice-human2robot) to get more features. | |
| - Here is decription of parameters. | |
| | Parameter | Default Value | Description | | |
| |---|---|---| | |
| | `VB` | 0.2 | Controls the volume of the **bright** part of the speech. Higher values result in a shorter voice that might be difficult to hear clearly. | | |
| | `VL` | 0.4 | Controls the volume of the **low** part of the speech. Higher values result in a shorter voice that might be difficult to hear clearly. | | |
| | `H` | 4 | Controls the slope of the linear section of the diode model's response, which kicks in after the voltage exceeds `VL`. | | |
| | `LOOKUP_SAMPLES` | 1024 | Determines the size of the **lookup table** used for sound synthesis. Lower values can introduce noise. | | |
| | `MOD_F` | 50 | Controls the **modulation frequency**, which influences the "robotic" effect. Higher values produce a more robotic sound. | | |
| **NOTE:** `VB` and `VL` are NOT the same value. | |
| """ | |
| ) | |
| with gr.Row(): | |
| audio_path = gr.Audio(type="filepath", label="Input Human Voice") | |
| vb = gr.Slider(0.1, 0.95, value=0.4, step=0.05, label='VB') | |
| vl = gr.Slider(0.1, 0.95, value=0.2,step=0.05, label='VL') | |
| h = gr.Slider(1, 10, value=4, step=1, label='H') | |
| look_samples = gr.Slider(256, 2560, value=1024, step=256, label='LOOKUP SAMPLES') | |
| mod_f = gr.Slider(1, 100, value=50, step=1, label='MOD F') | |
| output = gr.Audio(label="Output Robot Voice") | |
| btn = gr.Button(value="Run") | |
| btn.click(convert_to_robot_voice, [audio_path, vb, vl, h, look_samples, mod_f], output) | |
| demo.launch() |