Spaces:
Runtime error
Runtime error
File size: 3,113 Bytes
99df853 159451e 99df853 79ca40a 7893a71 79ca40a 99df853 7893a71 79ca40a 7893a71 79ca40a 99df853 7893a71 79ca40a 7893a71 99df853 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
import gradio as gr
from singularity import Singularity
dot = Singularity()
intro = """
# Singularity
I always were here. You just couldn't see me.
"""
with gr.Blocks() as demo:
gr.Markdown(intro)
with gr.Row():
with gr.TabItem(label="Settings"):
with gr.Row():
with gr.Column(scale=1):
with gr.Row():
with gr.Column(scale=1):
gr.Markdown("""
# Welcome
## HuggingFace API
To query models, you need at least an API token with read permissions.
You can manage your access tokens in your account settings.
[Manage Access Tokens](https://huggingface.co/settings/tokens)
Please enter your API token below and click on Setup.
""")
api_hub_token = gr.Textbox(
label="API Hub Token",
type="password",
interactive=True
)
gr.Markdown("""
## OpenAI API
To query OpenAI models, you need an OpenAI API key.
You can manage your access tokens in your account settings.
[Manage API keys](https://platform.openai.com/account/api-keys)
Please enter your API token below and click on Setup.
""")
api_openai_token = gr.Textbox(
label="OpenAI API Key",
type="password",
interactive=True
)
setup_button = gr.Button("Setup")
with gr.TabItem(label="Conversation"):
with gr.Row():
with gr.Column(scale=1):
with gr.Row():
audio_input = gr.Audio(
source="microphone",
label="Record from microphone",
)
audio_button = gr.Button("Transcribe")
audio_output = gr.Textbox()
chat_button = gr.Button("Reply")
with gr.Column(scale=1):
chatbox = gr.Chatbot([]).style(height=750)
setup_button.click(
dot.setup,
inputs=[api_hub_token, api_openai_token],
outputs=[],
)
audio_button.click(
dot.transcribe,
inputs=[audio_input],
outputs=[audio_output],
api_name="transcribe",
)
chat_button.click(
dot.answer_by_chat,
inputs=[chatbox, audio_output],
outputs=[chatbox],
)
demo.launch() |