Spaces:
Running
Running
Update lunacode.py
Browse files- lunacode.py +10 -0
lunacode.py
CHANGED
@@ -4,6 +4,9 @@ from bs4 import BeautifulSoup
|
|
4 |
from duckduckgo_search import DDGS
|
5 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
6 |
import wikipedia
|
|
|
|
|
|
|
7 |
|
8 |
model_path = "cosmosai471/Luna-v2"
|
9 |
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
@@ -89,6 +92,13 @@ def scrape_first_good_content(urls):
|
|
89 |
continue
|
90 |
return None, None
|
91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
def smart_luna_answer(user_question, max_tokens=512):
|
93 |
temperature, top_p = get_generation_params(user_question)
|
94 |
|
|
|
4 |
from duckduckgo_search import DDGS
|
5 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
6 |
import wikipedia
|
7 |
+
from gtts import gTTS
|
8 |
+
import os
|
9 |
+
import uuid
|
10 |
|
11 |
model_path = "cosmosai471/Luna-v2"
|
12 |
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
|
|
92 |
continue
|
93 |
return None, None
|
94 |
|
95 |
+
|
96 |
+
def text_to_speech_luna(text):
|
97 |
+
tts = gTTS(text=text, lang="en")
|
98 |
+
filename = f"/tmp/luna_reply_{uuid.uuid4().hex}.mp3"
|
99 |
+
tts.save(filename)
|
100 |
+
return filename
|
101 |
+
|
102 |
def smart_luna_answer(user_question, max_tokens=512):
|
103 |
temperature, top_p = get_generation_params(user_question)
|
104 |
|