Convert Video to Audio

Before converting Speech to Text, you will need to convert the video into audio using the moviepy library. You can install the library to your machine using the following command.

pip install moviepy

Use the following code block to import the library and do the conversion.

# Python code to convert video to audio
import moviepy.editor as mp

# Insert Local Video File Path
clip = mp.VideoFileClip(r"<ADD-PATH-TO-VIDEO-INPUT>")

# Insert Local Audio File Path
clip.audio.write_audiofile(r"<ADD-PATH-TO-AUDIO-OUTPUT>")

Source

Last updated

Was this helpful?