Update app.py
Browse files
app.py
CHANGED
@@ -9,6 +9,8 @@ import openai
|
|
9 |
import warnings
|
10 |
warnings.filterwarnings("ignore")
|
11 |
|
|
|
|
|
12 |
# Image-to-text
|
13 |
def img2txt(url):
|
14 |
print("Initializing captioning model...")
|
@@ -23,7 +25,7 @@ def img2txt(url):
|
|
23 |
# Text-to-story
|
24 |
def txt2story(img_text, top_k, top_p, temperature):
|
25 |
|
26 |
-
headers = {"Authorization": f"Bearer {
|
27 |
|
28 |
data = {
|
29 |
"model": "togethercomputer/llama-2-70b-chat",
|
@@ -47,7 +49,7 @@ def txt2story(img_text, top_k, top_p, temperature):
|
|
47 |
def txt2speech(text):
|
48 |
print("Initializing text-to-speech conversion...")
|
49 |
API_URL = "https://api-inference.huggingface.co/models/espnet/kan-bayashi_ljspeech_vits"
|
50 |
-
headers = {"Authorization": f"Bearer {
|
51 |
payloads = {'inputs': text}
|
52 |
|
53 |
response = requests.post(API_URL, headers=headers, json=payloads)
|
|
|
9 |
import warnings
|
10 |
warnings.filterwarnings("ignore")
|
11 |
|
12 |
+
api_token = os.getenv('H_TOKEN')
|
13 |
+
|
14 |
# Image-to-text
|
15 |
def img2txt(url):
|
16 |
print("Initializing captioning model...")
|
|
|
25 |
# Text-to-story
|
26 |
def txt2story(img_text, top_k, top_p, temperature):
|
27 |
|
28 |
+
headers = {"Authorization": f"Bearer {api_token}"}
|
29 |
|
30 |
data = {
|
31 |
"model": "togethercomputer/llama-2-70b-chat",
|
|
|
49 |
def txt2speech(text):
|
50 |
print("Initializing text-to-speech conversion...")
|
51 |
API_URL = "https://api-inference.huggingface.co/models/espnet/kan-bayashi_ljspeech_vits"
|
52 |
+
headers = {"Authorization": f"Bearer {api_token }"}
|
53 |
payloads = {'inputs': text}
|
54 |
|
55 |
response = requests.post(API_URL, headers=headers, json=payloads)
|