feat: mvp
This commit is contained in:
38
dubbing/steps/extract_audio.py
Normal file
38
dubbing/steps/extract_audio.py
Normal file
@@ -0,0 +1,38 @@
|
||||
import subprocess
|
||||
from rich.console import Console
|
||||
from dubbing.steps.base import PipelineStep
|
||||
|
||||
console = Console()
|
||||
|
||||
|
||||
class ExtractAudioStep(PipelineStep):
|
||||
name = "Extract audio"
|
||||
|
||||
def is_cached(self) -> bool:
|
||||
return self.paths.source_audio.exists()
|
||||
|
||||
def clean(self) -> None:
|
||||
if self.paths.source_audio.exists():
|
||||
self.paths.source_audio.unlink()
|
||||
|
||||
async def run(self) -> None:
|
||||
console.print("[cyan]Extracting audio from video...[/]")
|
||||
|
||||
subprocess.run(
|
||||
[
|
||||
"ffmpeg",
|
||||
"-y",
|
||||
"-i",
|
||||
str(self.paths.source_video),
|
||||
"-vn",
|
||||
"-acodec",
|
||||
"libmp3lame",
|
||||
"-q:a",
|
||||
"2",
|
||||
str(self.paths.source_audio),
|
||||
],
|
||||
capture_output=True,
|
||||
check=True,
|
||||
)
|
||||
|
||||
console.print("[green]✓ Audio extracted[/]")
|
||||
Reference in New Issue
Block a user