import gradio as gr | |
from huggingface_hub import hf_hub_file_upload | |
from pydub import AudioSegment | |
def convert_to_opus(file): | |
# mp3 νμΌμ μ½μ΄λ€μ λλ€. | |
audio = AudioSegment.from_file(file.name) | |
# opus νμΌλ‘ λ³νν©λλ€. | |
opus_file = file.name.replace(".mp3", ".opus") | |
audio.export(opus_file, format="opus") | |
# λ³νλ opus νμΌμ Hugging Face Spacesμ μ λ‘λν©λλ€. | |
url = hf_hub_file_upload(opus_file) | |
return url | |
iface = gr.Interface(convert_to_opus, "file", "file") | |
iface.launch() |