14 lines
414 B
Python
14 lines
414 B
Python
|
from pydub import AudioSegment
|
||
|
from whisper import load_model
|
||
|
|
||
|
def extract_audio_from_video(video_path: str) -> str:
|
||
|
audio = AudioSegment.from_file(video_path)
|
||
|
audio_path = "/tmp/temp_audio.wav"
|
||
|
audio.export(audio_path, format="wav")
|
||
|
return audio_path
|
||
|
|
||
|
def transcribe_audio(audio_path: str) -> str:
|
||
|
model = load_model("base")
|
||
|
result = model.transcribe(audio_path)
|
||
|
return result["text"]
|