File size: 2,794 Bytes
22fcccd
 
 
 
 
fe4d32a
4785ef3
 
fe4d32a
4785ef3
27930f9
aaf6c27
4785ef3
 
 
5def7e1
22fcccd
764c83f
 
 
 
 
 
786c551
 
 
 
 
 
764c83f
 
 
 
 
 
 
 
 
 
 
 
 
 
56828ad
4115dcf
786c551
 
4115dcf
 
764c83f
46bf1b5
764c83f
46bf1b5
22fcccd
786c551
6029664
3190c86
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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()