tayyardurden commited on
Commit
3bc0ed3
1 Parent(s): 3c874ee

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +11 -19
  2. requirements.txt +2 -2
app.py CHANGED
@@ -3,7 +3,6 @@ import streamlit as st
3
  import time
4
  import os
5
 
6
-
7
  os.environ['COQUI_TOS_AGREED'] = '1'
8
  os.environ['BARK_TOS_AGREED'] = '1'
9
 
@@ -19,11 +18,9 @@ def model_coqui():
19
 
20
  # @st.cache_resource()
21
  def model_bark():
22
- from transformers import AutoProcessor, BarkModel
23
- processor = AutoProcessor.from_pretrained("suno/bark")
24
- model = BarkModel.from_pretrained("suno/bark")
25
-
26
- return processor, model
27
 
28
 
29
  col1, col2 = st.columns(2)
@@ -59,19 +56,14 @@ if speaker:
59
  st.audio(output_path_coqui, format="audio/mp3")
60
 
61
  with col22:
 
 
62
 
63
- processor, model = model_bark()
64
- voice_preset = "tr_speaker_1"
65
- inputs = processor(f"{sentence}", voice_preset=voice_preset)
66
-
67
- start_time_bark = time.time() # Start the timer
68
- audio_array = model.generate(**inputs)
69
- end_time = time.time() # End the timer
70
-
71
- audio_array = audio_array.cpu().numpy().squeeze()
72
- sample_rate = model.generation_config.sample_rate
73
 
74
- execution_time = round(end_time - start_time_bark,2) # Calculate the time taken
75
- st.write(f"Bark için tamamlanma süresi: {execution_time} saniye") # Display the time taken
76
 
77
- st.audio(audio_array, format="audio/wav", sample_rate=sample_rate)
 
3
  import time
4
  import os
5
 
 
6
  os.environ['COQUI_TOS_AGREED'] = '1'
7
  os.environ['BARK_TOS_AGREED'] = '1'
8
 
 
18
 
19
  # @st.cache_resource()
20
  def model_bark():
21
+ device = "cpu"
22
+ tts = TTS("tts_models/multilingual/multi-dataset/bark").to(device)
23
+ return tts
 
 
24
 
25
 
26
  col1, col2 = st.columns(2)
 
56
  st.audio(output_path_coqui, format="audio/mp3")
57
 
58
  with col22:
59
+ tts_bark = model_bark()
60
+ speaker_wav_2 = "speaker_embeddings/tr_speaker_0"
61
 
62
+ start_time_bark = time.time()
63
+ output_path_bark = tts_bark.tts_to_file(text=sentence, speaker_wav=speaker_wav_2)
64
+ end_time = time.time()
 
 
 
 
 
 
 
65
 
66
+ execution_time = round(end_time - start_time_bark,2)
67
+ st.write(f"Bark içi tamamlanma süresi: {execution_time} saniye")
68
 
69
+ st.audio(output_path_bark, format="audio/mp3")
requirements.txt CHANGED
@@ -1,3 +1,3 @@
1
  streamlit
2
- TTS
3
- torch
 
1
  streamlit
2
+ git+https://github.com/coqui-ai/TTS
3
+ torch