tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

generate-test-files.py (1583B)


      1 #!/usr/bin/env python3
      2 
      3 import os
      4 
      5 rates = [44100, 48000]
      6 channels = [1, 2]
      7 duration = "0.5"
      8 frequency = "1000"
      9 volume = "-3dB"
     10 name = "half-a-second"
     11 formats = {
     12    "aac-in-adts": [{"codec": "aac", "extension": "aac"}],
     13    "mp3": [{"codec": "libmp3lame", "extension": "mp3"}],
     14    "mp4": [
     15        {
     16            "codec": "libopus",
     17            "extension": "mp4",
     18        },
     19        {"codec": "aac", "extension": "mp4"},
     20    ],
     21    "ogg": [
     22        {"codec": "libvorbis", "extension": "ogg"},
     23        {"codec": "libopus", "extension": "opus"},
     24    ],
     25    "flac": [
     26        {"codec": "flac", "extension": "flac"},
     27    ],
     28    "webm": [
     29        {"codec": "libopus", "extension": "webm"},
     30        {"codec": "libvorbis", "extension": "webm"},
     31    ],
     32 }
     33 
     34 for rate in rates:
     35    for channel_count in channels:
     36        wav_filename = f"{name}-{channel_count}ch-{rate}.wav"
     37        wav_command = f"sox -V -r {rate} -n -b 16 -c {channel_count} {wav_filename}  synth {duration} sin {frequency} vol {volume}"
     38        print(wav_command)
     39        os.system(wav_command)
     40        for container, codecs in formats.items():
     41            for codec in codecs:
     42                encoded_filename = "{}-{}ch-{}-{}.{}".format(
     43                    name, channel_count, rate, codec["codec"], codec["extension"]
     44                )
     45                print(encoded_filename)
     46                encoded_command = "ffmpeg -y -i {} -acodec {} {}".format(
     47                    wav_filename, codec["codec"], encoded_filename
     48                )
     49                print(encoded_command)
     50                os.system(encoded_command)