import gradio as gr import os import time # To add a short delay # Force install torch (though this should ideally be handled in requirements.txt) os.system("pip install torch") time.sleep(10) # Adding a short delay to ensure installation completes import torch from transformers import pipeline # Initialize the ASR pipeline for Bulgarian asr_pipeline = pipeline("automatic-speech-recognition", model="infinitejoy/wav2vec2-large-xls-r-300m-bulgarian") # ASR 변환 함수 (speech-to-text conversion) def asr_generate(audio): transcription = asr_pipeline(audio)["text"] return transcription # Gradio 인터페이스 생성 iface = gr.Interface( fn=asr_generate, inputs=gr.Audio(source="microphone", type="filepath"), outputs="text", title="Bulgarian Speech Recognition", description="Upload or record audio in Bulgarian to get the transcription." ) # 인터페이스 실행 if __name__ == "__main__": iface.launch()