Delete dataset-creation.py
Browse files- dataset-creation.py +0 -63
dataset-creation.py
DELETED
|
@@ -1,63 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import subprocess
|
| 3 |
-
from rich.console import Console
|
| 4 |
-
|
| 5 |
-
# Initialize Rich Console
|
| 6 |
-
console = Console()
|
| 7 |
-
console.clear()
|
| 8 |
-
|
| 9 |
-
# Title Screen
|
| 10 |
-
console.print("""[bold cyan]
|
| 11 |
-
=====================================
|
| 12 |
-
VIDEO TO AUDIO EXTRACTION TOOL
|
| 13 |
-
=====================================
|
| 14 |
-
[/bold cyan]""")
|
| 15 |
-
console.print("This tool extracts audio tracks from video files using FFmpeg.")
|
| 16 |
-
console.print("Input and output directories will be created in the same folder as this script.")
|
| 17 |
-
|
| 18 |
-
# Define Paths Relative to Script Location
|
| 19 |
-
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
| 20 |
-
INPUT_DIR = os.path.join(SCRIPT_DIR, "videos")
|
| 21 |
-
OUTPUT_DIR = os.path.join(SCRIPT_DIR, "wavs")
|
| 22 |
-
|
| 23 |
-
# Ensure Directories Exist
|
| 24 |
-
os.makedirs(INPUT_DIR, exist_ok=True)
|
| 25 |
-
os.makedirs(OUTPUT_DIR, exist_ok=True)
|
| 26 |
-
|
| 27 |
-
# Pause to allow user to populate videos directory
|
| 28 |
-
console.print(f"[bold yellow]Please add video files to the directory: {INPUT_DIR}[/bold yellow]")
|
| 29 |
-
input("\nPress Enter to continue...")
|
| 30 |
-
|
| 31 |
-
# Process Video Files
|
| 32 |
-
video_files = [f for f in sorted(os.listdir(INPUT_DIR)) if f.endswith((".mkv", ".mp4"))]
|
| 33 |
-
if not video_files:
|
| 34 |
-
console.print(f"[bold red]Error:[/bold red] No video files found in: {INPUT_DIR}", style="red")
|
| 35 |
-
exit(1)
|
| 36 |
-
|
| 37 |
-
console.print(f"[bold green]Found {len(video_files)} video file(s). Starting processing...[/bold green]")
|
| 38 |
-
for index, file_name in enumerate(video_files, start=1):
|
| 39 |
-
input_path = os.path.join(INPUT_DIR, file_name)
|
| 40 |
-
output_file = os.path.join(OUTPUT_DIR, f"{os.path.splitext(file_name)[0]}.wav")
|
| 41 |
-
|
| 42 |
-
# Construct FFmpeg command
|
| 43 |
-
ffmpeg_command = [
|
| 44 |
-
"ffmpeg",
|
| 45 |
-
"-i", input_path,
|
| 46 |
-
"-vn",
|
| 47 |
-
"-acodec", "pcm_s16le",
|
| 48 |
-
"-ar", "16000",
|
| 49 |
-
"-ac", "1",
|
| 50 |
-
output_file
|
| 51 |
-
]
|
| 52 |
-
|
| 53 |
-
console.print(f"Processing: [bold blue]{file_name}[/bold blue] ({index}/{len(video_files)})")
|
| 54 |
-
|
| 55 |
-
# Execute the FFmpeg command
|
| 56 |
-
try:
|
| 57 |
-
subprocess.run(ffmpeg_command, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
| 58 |
-
console.print(f"[bold green]Success:[/bold green] Extracted audio to: {output_file}", style="green")
|
| 59 |
-
except subprocess.CalledProcessError as e:
|
| 60 |
-
console.print(f"[bold red]Error processing {file_name}:[/bold red] {e}", style="red")
|
| 61 |
-
|
| 62 |
-
console.print("[bold green]All files processed successfully.[/bold green]")
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|