File size: 844 Bytes
b165e98
5d863dd
 
b165e98
5d863dd
 
b165e98
5d863dd
 
 
 
b165e98
5d863dd
 
 
 
 
 
b165e98
5d863dd
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr
import whisper
import base64

# Whisper ๋ชจ๋ธ ๋กœ๋“œ
model = whisper.load_model("base")

# ์Œ์„ฑ์„ ํ…์ŠคํŠธ๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜
def transcribe_audio(audio):
    result = model.transcribe(audio)
    return result["text"], base64.b64encode(result["text"].encode()).decode() #type: ignore

# Gradio ์ธํ„ฐํŽ˜์ด์Šค
demo = gr.Interface(fn=transcribe_audio,
    inputs=gr.Audio(label = '์˜ค๋””์˜ค', sources="microphone", type="filepath"),
    outputs=[gr.Textbox(label='๊ฒฐ๊ณผ'), gr.Textbox(label='์•”ํ˜ธํ™”๋œ ๊ฒฐ๊ณผ')],
    title='์ด์šฐ์ง„์˜ Speech to Text', 
    description='AI 60%, ๋‚˜ 40%  (AI ์ฝ”๋“œ 40๋ถ„๋™์•ˆ ๊ณ ์น˜๋‹ค๊ฐ€ new chat์œผ๋กœ ๋‹ค์‹œ ์งœ๋‹ˆ๊นŒ ๋ฐ”๋กœ๋จ) (Interface๋Š” ๋‚ด๊ฐ€๋งŒ๋“ฌ) (์ œ์ž‘์‹œ๊ฐ„ 1์‹œ๊ฐ„)')

# ์•ฑ ์‹คํ–‰
demo.launch(share=True, auth=('๊ฒฝ์ง„์”จ๋ฐ˜', '123456'))