File size: 545 Bytes
798b4d1
1ded5ed
 
798b4d1
1ded5ed
 
 
798b4d1
1ded5ed
 
 
 
 
 
 
 
 
 
798b4d1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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()