diff options
| author | Adam Soltys <[email protected]> | 2023-09-01 22:42:31 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-09-01 22:42:31 -0700 |
| commit | dd93caa76eee95ace50f05ca13a344bc3bc5ad4a (patch) | |
| tree | 8e7df182778f9e69afb56c4b25b90110a1c968ba | |
| parent | 46d0d781d546d2fb8a57e9b5d417de629a579b82 (diff) | |
| download | coinos-server-dd93caa76eee95ace50f05ca13a344bc3bc5ad4a.tar.gz coinos-server-dd93caa76eee95ace50f05ca13a344bc3bc5ad4a.zip | |
cleanup
| -rw-r--r-- | lib/payments.js | 17 |
1 files 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; |
