rahgadda commited on
Commit
ec66fcf
1 Parent(s): 5767f76

Initial Draft

Browse files
Files changed (1) hide show
  1. voice.py +14 -9
voice.py CHANGED
@@ -1,6 +1,7 @@
1
  import gradio as gr
2
  from transformers import AutoProcessor, BarkModel
3
  import scipy
 
4
 
5
  ############################
6
  ### Variable Declaration ###
@@ -8,11 +9,13 @@ import scipy
8
 
9
  # -- UI Variables
10
  ui_input_voice_presenter=gr.Dropdown(
11
- ["v2/en_speaker_0","v2/en_speaker_9"], label="Voice Presenter"
 
 
12
  )
13
  ui_input_filename=gr.Textbox(label="Input WAV Filename")
14
  ui_input_text=gr.Textbox(lines=22,label="Input Text")
15
- ui_output=gr.Audio(label="Output")
16
 
17
  # -- Model Variables
18
  processor = AutoProcessor.from_pretrained("suno/bark")
@@ -24,7 +27,7 @@ model = BarkModel.from_pretrained("suno/bark")
24
 
25
  # -- On Click of Submit Button in UI
26
  def submit(voice_presenter, filename, input_text):
27
- print("Hello World")
28
 
29
  inputs = processor(input_text, voice_preset=voice_presenter)
30
  audio_array = model.generate(**inputs)
@@ -32,17 +35,19 @@ def submit(voice_presenter, filename, input_text):
32
  sample_rate = model.generation_config.sample_rate
33
  scipy.io.wavfile.write(filename, rate=sample_rate, data=audio_array)
34
 
35
- return gr.Audio(source=[os.path.join(os.path.dirname(__file__),filename)])
 
 
36
 
37
  ############################
38
  ###### Main Program ########
39
  ############################
 
40
  ui_input_filename.value="sample.wav"
41
- ui_input_text.value = """
42
- Hello uh ... [clears throat],
43
- Bark is a transformer-based text-to-speech model proposed by Suno AI.
44
- This voice is auto generated
45
- """
46
 
47
  # -- Start of Program - Main
48
  def main():
 
1
  import gradio as gr
2
  from transformers import AutoProcessor, BarkModel
3
  import scipy
4
+ import os
5
 
6
  ############################
7
  ### Variable Declaration ###
 
9
 
10
  # -- UI Variables
11
  ui_input_voice_presenter=gr.Dropdown(
12
+ choices=["v2/en_speaker_0","v2/en_speaker_9"],
13
+ value=["v2/en_speaker_0"],
14
+ label="Voice Presenter"
15
  )
16
  ui_input_filename=gr.Textbox(label="Input WAV Filename")
17
  ui_input_text=gr.Textbox(lines=22,label="Input Text")
18
+ ui_output=gr.Audio(label="Output",value=os.path.join(os.path.dirname(__file__))+"/sample.wav")
19
 
20
  # -- Model Variables
21
  processor = AutoProcessor.from_pretrained("suno/bark")
 
27
 
28
  # -- On Click of Submit Button in UI
29
  def submit(voice_presenter, filename, input_text):
30
+ print("Started Generating Voice")
31
 
32
  inputs = processor(input_text, voice_preset=voice_presenter)
33
  audio_array = model.generate(**inputs)
 
35
  sample_rate = model.generation_config.sample_rate
36
  scipy.io.wavfile.write(filename, rate=sample_rate, data=audio_array)
37
 
38
+ print("Generation of Voice completed")
39
+
40
+ return os.path.join(os.path.dirname(__file__))+"/sample.wav"
41
 
42
  ############################
43
  ###### Main Program ########
44
  ############################
45
+ ui_input_voice_presenter.value="v2/en_speaker_0"
46
  ui_input_filename.value="sample.wav"
47
+ ui_input_text.value = """Hello uh ... [clears throat],
48
+ Bark is a transformer-based text-to-speech model proposed by Suno AI.
49
+ This voice is auto generated
50
+ """
 
51
 
52
  # -- Start of Program - Main
53
  def main():