Spaces:
Sleeping
Sleeping
Commit
•
3c874ee
1
Parent(s):
986c74b
Upload app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import streamlit as st
|
|
3 |
import time
|
4 |
import os
|
5 |
|
|
|
6 |
os.environ['COQUI_TOS_AGREED'] = '1'
|
7 |
os.environ['BARK_TOS_AGREED'] = '1'
|
8 |
|
@@ -18,9 +19,11 @@ def model_coqui():
|
|
18 |
|
19 |
# @st.cache_resource()
|
20 |
def model_bark():
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
24 |
|
25 |
|
26 |
col1, col2 = st.columns(2)
|
@@ -29,11 +32,11 @@ with col1:
|
|
29 |
sentence = st.text_area("Konuşmak istediğiniz metni girin")
|
30 |
|
31 |
with col2:
|
32 |
-
st.selectbox("Dil Seçin", ["Ceylin", "Funda"])
|
33 |
-
if
|
34 |
-
speaker_wav ="sounds/glinda.mp3"
|
35 |
else:
|
36 |
-
|
37 |
|
38 |
speaker=st.button("Seslendir")
|
39 |
|
@@ -47,7 +50,7 @@ if speaker:
|
|
47 |
with col11:
|
48 |
tts_coqui = model_coqui()
|
49 |
start_time_coqui = time.time() # Start the timer
|
50 |
-
output_path_coqui = tts_coqui.tts_to_file(text=sentence, speaker_wav=
|
51 |
end_time = time.time() # End the timer
|
52 |
|
53 |
execution_time = round(end_time - start_time_coqui,2) # Calculate the time taken
|
@@ -56,13 +59,19 @@ if speaker:
|
|
56 |
st.audio(output_path_coqui, format="audio/mp3")
|
57 |
|
58 |
with col22:
|
59 |
-
tts_bark = model_bark()
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
-
execution_time = round(end_time - start_time_bark,2)
|
66 |
-
st.write(f"Bark
|
67 |
|
68 |
-
st.audio(
|
|
|
3 |
import time
|
4 |
import os
|
5 |
|
6 |
+
|
7 |
os.environ['COQUI_TOS_AGREED'] = '1'
|
8 |
os.environ['BARK_TOS_AGREED'] = '1'
|
9 |
|
|
|
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)
|
|
|
32 |
sentence = st.text_area("Konuşmak istediğiniz metni girin")
|
33 |
|
34 |
with col2:
|
35 |
+
language = st.selectbox("Dil Seçin", ["Ceylin", "Funda"])
|
36 |
+
if language == "Ceylin":
|
37 |
+
speaker_wav = "sounds/glinda.mp3"
|
38 |
else:
|
39 |
+
speaker_wav = "sounds/alp.mp3"
|
40 |
|
41 |
speaker=st.button("Seslendir")
|
42 |
|
|
|
50 |
with col11:
|
51 |
tts_coqui = model_coqui()
|
52 |
start_time_coqui = time.time() # Start the timer
|
53 |
+
output_path_coqui = tts_coqui.tts_to_file(text=sentence, speaker_wav=speaker_wav ,language="tr")
|
54 |
end_time = time.time() # End the timer
|
55 |
|
56 |
execution_time = round(end_time - start_time_coqui,2) # Calculate the time taken
|
|
|
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)
|