import gradio as gr import requests import json from utils import get_story, get_voice_filename, get_musicgen_music, get_mubert_music with gr.Blocks() as performance: with gr.Tab("Story Generation"): chatbot = gr.Chatbot(label='GPT4', elem_id="chatbot") input_text = gr.Textbox(lines=2, label="시작 문장") input_number = gr.Number(label='문장수', value=20) state = gr.State([]) with gr.Row(): with gr.Column(): b1 = gr.Button().style(full_width=True) b1.click(get_story, [input_text, input_number, chatbot, state], [chatbot, state]) with gr.Tab("Voice Generation"): input_text = gr.Textbox(lines=10, label="문장") input_gender = gr.Radio(choices=["남성", "여성"], value="남성", label="성별") input_age = gr.Radio(choices=["청년", "중년"], value='청년', label="연령대") input_speed = gr.Slider(minimum=0, maximum=5, step=1, value=1, label="속도") input_pitch = gr.Slider(minimum=0, maximum=5, step=1, value=1, label="음색") input_alpha = gr.Slider(minimum=-5, maximum=0, step=1, value=-1, label="높낮이") with gr.Row(): with gr.Column(): b2 = gr.Button().style(full_width=True) b2.click(get_voice_filename, [input_text, input_gender, input_age, input_speed, input_pitch, input_alpha], [gr.Audio(label="결과 음성 파일", type="filepath")]) with gr.Tab("Music Generation - MusicGen"): input_text = gr.Textbox(lines=10, label="문장") input_duration = gr.Number(label="음악 시간(s)", value=30) with gr.Row(): with gr.Column(): b3 = gr.Button().style(full_width=True) b3.click(get_musicgen_music, [input_text, input_duration], gr.Audio(label="결과 음악 파일", type='filepath')) # with gr.Tab("Music Generation - Mubert"): # input_text = gr.Textbox(lines=10, label="문장") # input_duration = gr.Number(label="음악 시간(s)", value=30) # with gr.Row(): # with gr.Column(): # b3 = gr.Button().style(full_width=True) # b3.click(get_mubert_music, [input_text, input_duration], gr.Audio(label="결과 음악 파일", type='filepath')) performance.queue().launch()