Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,21 +1,21 @@
|
|
1 |
import os
|
2 |
import re
|
3 |
import gradio as gr
|
4 |
-
import edge_tts
|
5 |
import asyncio
|
6 |
import time
|
7 |
import tempfile
|
8 |
from huggingface_hub import InferenceClient
|
|
|
9 |
|
10 |
-
DESCRIPTION = """
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
|
15 |
-
MORE = """ ## TRY Other Models
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
|
20 |
Fast = """## Fastest Model"""
|
21 |
|
@@ -25,7 +25,7 @@ Detail = """## Best for Detailed Generation or Long Answers"""
|
|
25 |
|
26 |
client1 = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
27 |
|
28 |
-
system_instructions1 = "
|
29 |
|
30 |
async def generate1(prompt):
|
31 |
generate_kwargs = dict(
|
@@ -43,10 +43,10 @@ async def generate1(prompt):
|
|
43 |
for response in stream:
|
44 |
output += response.token.text
|
45 |
|
46 |
-
|
47 |
-
with tempfile.NamedTemporaryFile(delete=False, suffix=".
|
48 |
tmp_path = tmp_file.name
|
49 |
-
|
50 |
yield tmp_path
|
51 |
|
52 |
client2 = InferenceClient("meta-llama/Meta-Llama-3-70B-Instruct")
|
@@ -68,10 +68,10 @@ async def generate2(prompt):
|
|
68 |
for response in stream:
|
69 |
output += response.token.text
|
70 |
|
71 |
-
|
72 |
-
with tempfile.NamedTemporaryFile(delete=False, suffix=".
|
73 |
tmp_path = tmp_file.name
|
74 |
-
|
75 |
yield tmp_path
|
76 |
|
77 |
client3 = InferenceClient("meta-llama/Meta-Llama-3-70B-Instruct")
|
@@ -93,10 +93,10 @@ async def generate3(prompt):
|
|
93 |
for response in stream:
|
94 |
output += response.token.text
|
95 |
|
96 |
-
|
97 |
-
with tempfile.NamedTemporaryFile(delete=False, suffix=".
|
98 |
tmp_path = tmp_file.name
|
99 |
-
|
100 |
yield tmp_path
|
101 |
|
102 |
with gr.Blocks(css="style.css") as demo:
|
|
|
1 |
import os
|
2 |
import re
|
3 |
import gradio as gr
|
|
|
4 |
import asyncio
|
5 |
import time
|
6 |
import tempfile
|
7 |
from huggingface_hub import InferenceClient
|
8 |
+
from gtts import gTTS
|
9 |
|
10 |
+
DESCRIPTION = """ <center><b>JARVIS⚡</b></center> \
|
11 |
+
### <center>A personal Assistant of Tony Stark for YOU \
|
12 |
+
### <center>Currently It supports text input, But If this space completes 1k hearts than I starts working on Audio Input.</center> \
|
13 |
+
"""
|
14 |
|
15 |
+
MORE = """ ## TRY Other Models \
|
16 |
+
### Instant Video: Create Amazing Videos in 5 Second -> https://huggingface.co/spaces/KingNish/Instant-Video \
|
17 |
+
### Instant Image: 4k images in 5 Second -> https://huggingface.co/spaces/KingNish/Instant-Image \
|
18 |
+
"""
|
19 |
|
20 |
Fast = """## Fastest Model"""
|
21 |
|
|
|
25 |
|
26 |
client1 = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
27 |
|
28 |
+
system_instructions1 = " [SYSTEM] Answer as Real Jarvis JARVIS, Made by 'Tony Stark', Keep conversation very short, clear, friendly and concise. The text provided is a request for a specific type of response from you, the virtual assistant. The request asks you to provide friendly responses as if You are the character Jarvis, made by 'Tony Stark.' The expectation is that I will avoid introductions and start answering the query directly, elaborating on all aspects of the request. As an AI-powered assistant, your task is to generate responses that appear as if they are created by the user and not an AI-powered assistant. [USER]"
|
29 |
|
30 |
async def generate1(prompt):
|
31 |
generate_kwargs = dict(
|
|
|
43 |
for response in stream:
|
44 |
output += response.token.text
|
45 |
|
46 |
+
tts = gTTS(output, lang="ko")
|
47 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
|
48 |
tmp_path = tmp_file.name
|
49 |
+
tts.save(tmp_path)
|
50 |
yield tmp_path
|
51 |
|
52 |
client2 = InferenceClient("meta-llama/Meta-Llama-3-70B-Instruct")
|
|
|
68 |
for response in stream:
|
69 |
output += response.token.text
|
70 |
|
71 |
+
tts = gTTS(output, lang="ko")
|
72 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
|
73 |
tmp_path = tmp_file.name
|
74 |
+
tts.save(tmp_path)
|
75 |
yield tmp_path
|
76 |
|
77 |
client3 = InferenceClient("meta-llama/Meta-Llama-3-70B-Instruct")
|
|
|
93 |
for response in stream:
|
94 |
output += response.token.text
|
95 |
|
96 |
+
tts = gTTS(output, lang="ko")
|
97 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
|
98 |
tmp_path = tmp_file.name
|
99 |
+
tts.save(tmp_path)
|
100 |
yield tmp_path
|
101 |
|
102 |
with gr.Blocks(css="style.css") as demo:
|