Shyamchandar commited on
Commit
c5959b3
·
verified ·
1 Parent(s): 1e1e467

Upload 5 files

Browse files
Files changed (6) hide show
  1. .env +0 -0
  2. .gitattributes +2 -0
  3. app.py +62 -0
  4. bg.jpg +3 -0
  5. output.wav +3 -0
  6. requirements.txt +7 -3
.env ADDED
File without changes
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ bg.jpg filter=lfs diff=lfs merge=lfs -text
37
+ output.wav filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import base64
2
+
3
+ import streamlit as st
4
+ import torch
5
+ import soundfile as sf
6
+ from kokoro import KPipeline
7
+
8
+
9
+ def get_base64_of_bin_file(bin_file):
10
+ with open(bin_file, 'rb') as f:
11
+ data = f.read()
12
+ return base64.b64encode(data).decode()
13
+
14
+ def set_png_as_page_bg(png_file):
15
+ bin_str = get_base64_of_bin_file(png_file)
16
+ page_bg_img = f"""
17
+ <style>
18
+ .stApp {{
19
+ background-image: url("data:image/png;base64,{bin_str}");
20
+ background-size: cover;
21
+ background-repeat: no-repeat;
22
+ background-attachment: fixed; /* Optional: keeps background fixed on scroll */
23
+ }}
24
+ </style>
25
+ """
26
+ st.markdown(page_bg_img, unsafe_allow_html=True)
27
+
28
+ @st.cache_resource
29
+ def load_pipeline():
30
+ return KPipeline(lang_code='a') # change lang if needed
31
+
32
+ pipeline = load_pipeline()
33
+
34
+ image_path = "bg.jpg"
35
+ set_png_as_page_bg(image_path)
36
+
37
+ st.title("Text to Voice Bot")
38
+
39
+
40
+ text = st.text_area("Enter text to convert into speech:", "")
41
+ voice = st.selectbox("Choose a voice", ["af_bella", "af_nicole", "am_adam", "bf_alice", "bm_george", "bm_lewis"])
42
+
43
+ if st.button("🔊 Generate Voice"):
44
+ if text.strip():
45
+ generator = pipeline(text, voice=voice, speed=1.0)
46
+ audio_path = "output.wav"
47
+
48
+ with sf.SoundFile(audio_path, "w", samplerate=24000, channels=1) as f:
49
+ for _, _, audio in generator:
50
+ f.write(audio)
51
+
52
+ st.audio(audio_path, format="audio/wav")
53
+ with open(audio_path, "rb") as audio_file:
54
+ st.download_button(
55
+ label="⬇️ Download Audio",
56
+ data=audio_file,
57
+ file_name="output.wav",
58
+ mime="audio/wav"
59
+ )
60
+ st.success("✅ Voice generated successfully!")
61
+ else:
62
+ st.warning("⚠️ Please enter some text.")
bg.jpg ADDED

Git LFS Details

  • SHA256: 85b1ac61df5a1f3ceb8ef1e74a5e603a80426c3c2535be599f611eb7acf842f5
  • Pointer size: 131 Bytes
  • Size of remote file: 105 kB
output.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1e1ccf9d81cec17e0f56fd1736a52b311f192ecfbb6bd68c8fbf6a15d11802d6
3
+ size 788444
requirements.txt CHANGED
@@ -1,3 +1,7 @@
1
- altair
2
- pandas
3
- streamlit
 
 
 
 
 
1
+ streamlit
2
+ torch
3
+ torchaudio
4
+ transformers
5
+ soundfile
6
+ kokoro
7
+ base64