import gradio as gr from transformers import pipeline # gradio_client 라이브러리 사용 가정 # 이미지 인식 파이프라인 로드 image_model = pipeline("image-classification", model="google/vit-base-patch16-224") def generate_voice(prompt): # Tango API를 사용하여 음성 생성 (가정) return "https://example.com/generated_voice.mp3" # 예시 음성 파일 URL 반환 def classify_and_generate_voice(uploaded_image): # 이미지 분류 predictions = image_model(uploaded_image) top_prediction = predictions[0]['label'] # 음성 생성 voice_result = generate_voice(top_prediction) return top_prediction, voice_result # Gradio 인터페이스 생성 및 예시 이미지 설정 iface = gr.Interface( fn=classify_and_generate_voice, inputs=gr.Image(type="pil"), outputs=[gr.Label(), gr.Audio()], examples=[["dog.jpg"]], # 예시 이미지 경로를 리스트로 추가 title="이미지 분류 및 음성 생성", description="이미지를 업로드하면, 사물을 인식하고 해당하는 음성을 생성합니다." ) # 인터페이스 실행 if __name__ == "__main__": iface.launch(share=True)