From 68a2aede36519b4d5891c9427e5cddc699082189 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 1 Sep 2023 22:42:31 -0700 Subject: cleanup --- lib/payments.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/payments.js b/lib/payments.js index 72beaac6..c8e74201 100644 --- a/lib/payments.js +++ b/lib/payments.js @@ -185,10 +185,14 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => { parseFloat(((amount * p.rate) / 100000000).toFixed(2)) ); - const client = mqtt.connect("mqtt://ln.coinos.io", config.mqtt); - const raw = `/app/data/uploads/${p.id}-raw.mp3`; - const out = `/app/data/uploads/${p.id}.mp3`; - const mimic = spawn("/mimic", [ + let client = mqtt.connect("mqtt://ln.coinos.io", config.mqtt); + client.subscribe(username); + + let raw = `/app/data/uploads/${p.id}-raw.mp3`; + let out = `/app/data/uploads/${p.id}.mp3`; + + let connected; + let mimic = spawn("/mimic", [ "-t", words, "-voice", @@ -196,9 +200,6 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => { "-o", raw ]); - let connected; - - client.subscribe(username); mimic.stdout.on("end", async () => { await wait(() => connected); @@ -233,6 +234,7 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => { for (let n of missing) send(chunk); client.publish(username, `end:${n}`); } + }); ffmpeg(raw) .audioBitrate(128) @@ -267,7 +269,6 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => { ); setTimeout(() => (connected = true), 50); }); - }); } return p; -- cgit v1.2.3