Spaces:
Sleeping
Sleeping
Commit ·
31aa4c1
1
Parent(s): c1ee4ca
fix: Add support for .wav files in LFS and update audio handling in app.py
Browse files- .gitattributes +1 -0
- .gitignore +13 -0
- app.py +3 -3
- backend/tts.py +1 -1
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ 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 |
+
*.wav filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.venv/
|
| 2 |
+
.env
|
| 3 |
+
venv/
|
| 4 |
+
env/
|
| 5 |
+
__pycache__/
|
| 6 |
+
*.pyc
|
| 7 |
+
.DS_Store
|
| 8 |
+
*.npy
|
| 9 |
+
*.wav
|
| 10 |
+
*.mp3
|
| 11 |
+
*.pem
|
| 12 |
+
test.py
|
| 13 |
+
test.ipynb
|
app.py
CHANGED
|
@@ -19,7 +19,7 @@ if get_device() == "mps":
|
|
| 19 |
load_dotenv(override=True)
|
| 20 |
|
| 21 |
|
| 22 |
-
phone_waiting_sound = AudioSegment.from_mp3("frontend/phone-ringing-
|
| 23 |
sound_samples = np.array(phone_waiting_sound.get_array_of_samples(), dtype=np.int16)
|
| 24 |
if phone_waiting_sound.channels > 1:
|
| 25 |
sound_samples = sound_samples.reshape((-1, phone_waiting_sound.channels)).mean(axis=1)
|
|
@@ -28,7 +28,7 @@ def startup(_):
|
|
| 28 |
yield (phone_waiting_sound.frame_rate, sound_samples)
|
| 29 |
STARTUP_MESSAGE = "สวัสดีค่ะ พลอย 1577Homeshopping ยินดีให้บริการค่ะ"
|
| 30 |
yield from synthesize_text(STARTUP_MESSAGE)
|
| 31 |
-
time.sleep(
|
| 32 |
yield AdditionalOutputs([{"role": "assistant", "content": STARTUP_MESSAGE}])
|
| 33 |
|
| 34 |
custom_css = """
|
|
@@ -476,5 +476,5 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft(primary_hue="orange", second
|
|
| 476 |
show_progress="hidden"
|
| 477 |
)
|
| 478 |
|
| 479 |
-
demo.queue(default_concurrency_limit=
|
| 480 |
demo.launch(debug=True, show_error=True, share=True)
|
|
|
|
| 19 |
load_dotenv(override=True)
|
| 20 |
|
| 21 |
|
| 22 |
+
phone_waiting_sound = AudioSegment.from_mp3("frontend/phone-ringing-24000.wav")
|
| 23 |
sound_samples = np.array(phone_waiting_sound.get_array_of_samples(), dtype=np.int16)
|
| 24 |
if phone_waiting_sound.channels > 1:
|
| 25 |
sound_samples = sound_samples.reshape((-1, phone_waiting_sound.channels)).mean(axis=1)
|
|
|
|
| 28 |
yield (phone_waiting_sound.frame_rate, sound_samples)
|
| 29 |
STARTUP_MESSAGE = "สวัสดีค่ะ พลอย 1577Homeshopping ยินดีให้บริการค่ะ"
|
| 30 |
yield from synthesize_text(STARTUP_MESSAGE)
|
| 31 |
+
time.sleep(1)
|
| 32 |
yield AdditionalOutputs([{"role": "assistant", "content": STARTUP_MESSAGE}])
|
| 33 |
|
| 34 |
custom_css = """
|
|
|
|
| 476 |
show_progress="hidden"
|
| 477 |
)
|
| 478 |
|
| 479 |
+
demo.queue(default_concurrency_limit=10)
|
| 480 |
demo.launch(debug=True, show_error=True, share=True)
|
backend/tts.py
CHANGED
|
@@ -42,7 +42,7 @@ def synthesize_text(text: str, lang = 'th' , speed = 2.0):
|
|
| 42 |
'พ.ศ.': 'พอศอ', '. ': ' ', '-19': ' 19', 'เพื่อยก': 'เพื่อ ยก',
|
| 43 |
'√': 'เครื่องหมายติ๊กถูก', '=>': 'จากนั้นเลือก', 'รอกด': 'รอ กด', ' ณ ': ' นะ ',
|
| 44 |
'[2ฟรี1]': 'สองฟรีหนึ่ง', "+": 'บวก', "12X": "สิบสองเอ็กซ์", "12x": "สิบสองเอ็กซ์",'[2ฟร2]': 'สองฟรีสอง',
|
| 45 |
-
"/": "ทับ", 'leading name': ''
|
| 46 |
|
| 47 |
}
|
| 48 |
for old, new in replacements.items():
|
|
|
|
| 42 |
'พ.ศ.': 'พอศอ', '. ': ' ', '-19': ' 19', 'เพื่อยก': 'เพื่อ ยก',
|
| 43 |
'√': 'เครื่องหมายติ๊กถูก', '=>': 'จากนั้นเลือก', 'รอกด': 'รอ กด', ' ณ ': ' นะ ',
|
| 44 |
'[2ฟรี1]': 'สองฟรีหนึ่ง', "+": 'บวก', "12X": "สิบสองเอ็กซ์", "12x": "สิบสองเอ็กซ์",'[2ฟร2]': 'สองฟรีสอง',
|
| 45 |
+
"/": "ทับ", 'leading name': '', " | ": " ","|":""
|
| 46 |
|
| 47 |
}
|
| 48 |
for old, new in replacements.items():
|