Update app.py
Browse files
app.py
CHANGED
|
@@ -1,31 +1,20 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from transformers import
|
| 3 |
-
import scipy.io.wavfile
|
| 4 |
-
import numpy as np
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
|
| 8 |
-
model = BarkModel.from_pretrained("suno/bark")
|
| 9 |
-
model.to("cuda") # अगर GPU उपलब्ध है
|
| 10 |
|
| 11 |
-
def
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
return "output.wav"
|
| 18 |
|
| 19 |
with gr.Blocks() as demo:
|
| 20 |
-
gr.
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
generate_button.click(
|
| 25 |
-
fn=generate_speech,
|
| 26 |
-
inputs=text_input,
|
| 27 |
-
outputs=audio_output
|
| 28 |
-
)
|
| 29 |
|
| 30 |
demo.launch()
|
| 31 |
-
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
# AI मॉडल लोड करें (यहां text-generation के लिए)
|
| 5 |
+
model = pipeline("text-generation", model="gpt2")
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
def respond(message, chat_history):
|
| 8 |
+
# AI मॉडल से रिस्पॉन्स लें
|
| 9 |
+
response = model(message, max_length=50)[0]["generated_text"]
|
| 10 |
+
chat_history.append({"role": "user", "content": message})
|
| 11 |
+
chat_history.append({"role": "assistant", "content": response})
|
| 12 |
+
return "", chat_history
|
|
|
|
| 13 |
|
| 14 |
with gr.Blocks() as demo:
|
| 15 |
+
chatbot = gr.Chatbot(type="messages")
|
| 16 |
+
msg = gr.Textbox(label="Type your message")
|
| 17 |
+
clear = gr.ClearButton([msg, chatbot])
|
| 18 |
+
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
demo.launch()
|
|
|