Tune speaker output parameter from ffmpeg
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
@@ -15,8 +16,8 @@ BASE = f"https://{HOST}/proxy/protect/integration/v1"
|
||||
PRIVATE_BASE = f"https://{HOST}/proxy/protect/api"
|
||||
|
||||
CAMERA_NAME = "G6 Pro 360"
|
||||
AUDIO_FILE = "./data/hello.wav"
|
||||
SPEAKER_VOLUME = 100 # 0-100
|
||||
DEFAULT_AUDIO_FILE = "./data/hello.wav"
|
||||
DEFAULT_SPEAKER_VOLUME = 75 # 0-100, above ~85 overdrives the amp
|
||||
|
||||
|
||||
def set_speaker_volume(camera_id: str, volume: int):
|
||||
@@ -48,18 +49,25 @@ def set_speaker_volume(camera_id: str, volume: int):
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Play audio through the G6 Pro 360 speaker")
|
||||
parser.add_argument("file", nargs="?", default=DEFAULT_AUDIO_FILE, help="Audio file to play (default: %(default)s)")
|
||||
parser.add_argument("-v", "--volume", type=int, default=DEFAULT_SPEAKER_VOLUME, metavar="0-100", help="Speaker volume 0-100 (default: %(default)s)")
|
||||
args = parser.parse_args()
|
||||
|
||||
with httpx.Client(headers={"X-API-Key": API_KEY}, verify=False) as client:
|
||||
cameras = client.get(f"{BASE}/cameras").raise_for_status().json()
|
||||
camera = next(c for c in cameras if CAMERA_NAME in c["name"])
|
||||
print(f"Camera: {camera['name']} ({camera['id']})")
|
||||
|
||||
set_speaker_volume(camera["id"], SPEAKER_VOLUME)
|
||||
set_speaker_volume(camera["id"], args.volume)
|
||||
|
||||
session = client.post(f"{BASE}/cameras/{camera['id']}/talkback-session").raise_for_status().json()
|
||||
print(f"Talkback: {session['url']} ({session['codec']} {session['samplingRate']}Hz)")
|
||||
|
||||
proc = subprocess.Popen([
|
||||
"ffmpeg", "-re", "-i", AUDIO_FILE,
|
||||
"ffmpeg", "-re", "-i", args.file,
|
||||
"-vn",
|
||||
"-af", "volume=0.8,highpass=f=200,treble=g=-9:f=4000,equalizer=f=1000:width_type=o:width=1:g=3,alimiter=limit=0.8:level=false",
|
||||
"-acodec", "libopus",
|
||||
"-ar", str(session["samplingRate"]),
|
||||
"-ac", "1",
|
||||
|
||||
Reference in New Issue
Block a user