Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,4 @@
|
|
1 |
-
from TTS.api import TTS
|
2 |
from llama_cpp import Llama
|
3 |
-
import pygame
|
4 |
-
import time
|
5 |
-
import re
|
6 |
-
|
7 |
-
def clean_text(text):
|
8 |
-
emoji_pattern = re.compile("["
|
9 |
-
u"\U0001F600-\U0001F64F"
|
10 |
-
u"\U0001F300-\U0001F5FF"
|
11 |
-
u"\U0001F680-\U0001F6FF"
|
12 |
-
u"\U0001F1E0-\U0001F1FF"
|
13 |
-
"]+", flags=re.UNICODE)
|
14 |
-
return emoji_pattern.sub(r'', text).strip()
|
15 |
-
|
16 |
-
def play_audio(file_path):
|
17 |
-
pygame.mixer.init()
|
18 |
-
pygame.mixer.music.load(file_path)
|
19 |
-
pygame.mixer.music.play()
|
20 |
-
while pygame.mixer.music.get_busy():
|
21 |
-
time.sleep(1)
|
22 |
-
|
23 |
# Llama model konfigürasyonu
|
24 |
llama = Llama.from_pretrained(
|
25 |
repo_id="ytu-ce-cosmos/Turkish-Llama-8b-Instruct-v0.1-GGUF",
|
@@ -73,9 +52,3 @@ while True:
|
|
73 |
answer = response['choices'][0]['text']
|
74 |
answer = clean_text(answer)
|
75 |
print(answer)
|
76 |
-
|
77 |
-
# TTS işlemleri
|
78 |
-
tts = TTS(model_name="tts_models/tr/common-voice/glow-tts",
|
79 |
-
vocoder_path="vocoder_models/tr/common-voice/hifigan").to("cpu")
|
80 |
-
tts.tts_to_file(text=answer, file_path='output.wav')
|
81 |
-
play_audio('output.wav')
|
|
|
|
|
1 |
from llama_cpp import Llama
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
# Llama model konfigürasyonu
|
3 |
llama = Llama.from_pretrained(
|
4 |
repo_id="ytu-ce-cosmos/Turkish-Llama-8b-Instruct-v0.1-GGUF",
|
|
|
52 |
answer = response['choices'][0]['text']
|
53 |
answer = clean_text(answer)
|
54 |
print(answer)
|
|
|
|
|
|
|
|
|
|
|
|