Skip to content

Instantly share code, notes, and snippets.

Last active Feb 17, 2020
What would you like to do?
Used to process a satnogs ogg audio file for loading in WxToImg GUI
import os
import sys
import wave
from datetime import datetime, timedelta
from dateutil import tz
# example satnogs_1692904_2020-02-14T10-24-03.ogg
if len(sys.argv) == 2:
fn = sys.argv[1]
fn_split = fn.split("_") # gives ["satnogs", "1692904", "2020-02-14T10-24-03.ogg"]
if len(fn_split) == 3:
date_string = fn_split[2][:-4] # chop off .ogg
dt_utc = datetime.strptime(date_string, "%Y-%m-%dT%H-%M-%S")
dt_utc = dt_utc.replace(tzinfo=tz.tzutc()) # set UTC as the time zone
dt_local = dt_utc.astimezone(tz.tzlocal()) # convert to local time stamp
fn_wav = fn.replace("ogg", "wav")
print("Converting ogg to wav...")
os.system("sox %s -r 11025 %s" % (fn, fn_wav))
with, 'r') as f:
wav_frames = f.getnframes()
wav_rate = f.getframerate()
wav_duration = wav_frames / float(wav_rate)
dt_final = dt_local + timedelta(seconds=wav_duration)
print("Updating time stamp...")
os.system("touch %s --date=\"%s\"" % (fn_wav, dt_final.strftime("%Y-%m-%d %H:%M:%S")))

This comment has been minimized.

Copy link
Owner Author

@davidhoness davidhoness commented Feb 17, 2020


chmod +x
./ satnogs_1692904_2020-02-14T10-24-03.ogg

Then File / Open Audio File in WXtoImg
Browse to satnogs_1692904_2020-02-14T10-24-03.wav

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment