Spaces:
Running
Running
Update utils/tts.py
Browse files- utils/tts.py +11 -0
utils/tts.py
CHANGED
@@ -2,11 +2,22 @@ import requests
|
|
2 |
import os
|
3 |
from dotenv import load_dotenv
|
4 |
import json
|
|
|
5 |
|
6 |
load_dotenv()
|
7 |
API_KEY = os.getenv("DG_API_KEY")
|
8 |
AUDIO_FILE=r".\media\ouput_file.mp3"
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
def text_to_speech(llm_response):
|
11 |
# Define the API endpoint
|
12 |
url = "https://api.deepgram.com/v1/speak?model=aura-asteria-en"
|
|
|
2 |
import os
|
3 |
from dotenv import load_dotenv
|
4 |
import json
|
5 |
+
import pyttsx3
|
6 |
|
7 |
load_dotenv()
|
8 |
API_KEY = os.getenv("DG_API_KEY")
|
9 |
AUDIO_FILE=r".\media\ouput_file.mp3"
|
10 |
|
11 |
+
engine = pyttsx3.init()
|
12 |
+
voices = engine.getProperty('voices')
|
13 |
+
engine.setProperty('voice', voices[1].id)
|
14 |
+
|
15 |
+
|
16 |
+
def text_to_speech2(llm_response):
|
17 |
+
engine.save_to_file(llm_response, AUDIO_FILE)
|
18 |
+
engine.runAndWait()
|
19 |
+
|
20 |
+
|
21 |
def text_to_speech(llm_response):
|
22 |
# Define the API endpoint
|
23 |
url = "https://api.deepgram.com/v1/speak?model=aura-asteria-en"
|