From df2340e0eee79f03dd03b33b622c9d3b81fcbc9e Mon Sep 17 00:00:00 2001 From: Dovi Cowan Date: Thu, 3 Aug 2023 19:29:29 +0100 Subject: [PATCH] start AWS provider code cleanup --- lib/provider.js | 145 ------------------------------------------------ 1 file changed, 145 deletions(-) diff --git a/lib/provider.js b/lib/provider.js index 22dd4d1..e42f2fc 100644 --- a/lib/provider.js +++ b/lib/provider.js @@ -261,137 +261,6 @@ class GoogleProvider extends Writable { return; } - this.cork(); // Buffer any incoming data - - this.recognizeStream.end(); - this.recognizeStream = null; - } - - /** - * Restarts the recognition stream. - * - * @param {Object} [config] - configuration to use - * @param {Object} [config.codec] - the codec to map to an encoding - * @param {string} [config.language] - the language to use - */ - restart(config) { - this.stop(); - this.start(config); - } -}; - -// class AWSProvider extends Writable { -// constructor(options) { -// super(); - -// this.LanguageCode = "en-GB"; -// this.MediaEncoding = "pcm"; -// this.credentials = { - // accessKeyId: process.env.AWS_ACCESS_KEY_ID, - // secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY, -// } - -// this.results = []; -// this.stream = new TransformStream(); -// this.recognizeStream = this.stream.writable.getWriter(); - -// (async () => { -// this.readStream = this.stream.readable; - -// this.config = { -// LanguageCode: this.LanguageCode, -// MediaEncoding: this.MediaEncoding, -// MediaSampleRateHertz: "8000", -// AudioStream: (async function* () { -// for await (const chunk of this.stream.readable.read()) { -// yield {AudioEvent: {AudioChunk: chunk}}; -// } -// // for (let result = await this.readStream.read(); !result.done; result = await this.readStream.read()) { -// // return {AudioEvent: {AudioChunk: result}}; -// // } -// })(), -// // AudioStream: this.readStream.read(), -// } -// }) - - -// this.command = null; -// } - -// _construct(callback) { -// this.client = new TranscribeStreamingClient({ -// region: "eu-west-2", -// credentials: this.credentials -// }); - -// callback(); -// } - -// _write(chunk, encoding, callback) { -// if (this.recognizeStream) { -// console.debug("writing chunk"); -// this.recognizeStream.write(chunk); -// } - -// callback(); -// } - -// setConfig(config) { -// if (!config) { -// return; -// } - -// } - -// start(config) { -// if (this.command) { -// return; -// } - -// this.setConfig(config); -// config = this.config; - -// // this.config.AudioStream = this.recognizeStream; - -// this.command = new StartStreamTranscriptionCommand(this.config) -// console.debug("command created") - -// this.client.send(this.command).then((response) => { -// print("response from command"); -// console.debug(response) -// }).catch((err) => { -// console.log("error in command"); -// console.debug(err); -// }) -// // (async function() { -// // // console.debug("start async") -// // this.results = await this.client.send(this.command); -// // // .then(async (response) => { -// // // console.debug(JSON.stringify(response)); -// // // }).catch(err => { -// // // console.debug("error"); -// // // console.debug(err); - -// // // }); -// // try { -// // // console.debug("event"); -// // for await (const event of this.results.TranscriptResultStream) { -// // console.log(JSON.stringify(event)); -// // } -// // } catch (err) { -// // console.log("error") -// // console.log(err) -// // } -// // })(); - -// // console.debug("AWSProvider"); -// } - -// restart(config) { -// this.start(config); -// } -// } - class AWSProvider extends Writable { constructor(options) { super(); @@ -481,12 +350,6 @@ class AWSProvider extends Writable { } } - // audioStream().next().then(res => console.debug(res.value.AudioEvent.AudioChunk)); - - // console.debug('AUDIO'); - // this.audioStream().next().then(res => console.debug(res)); - // this.audioStream().next().then(res => console.debug(res)); - this.param = { LanguageCode: this.LanguageCode, MediaEncoding: this.MediaEncoding, @@ -512,19 +375,12 @@ class AWSProvider extends Writable { } // Print all the possible transcripts - // - // }); } }; }).catch((err) => { console.debug(err); }) return; - - (async () => { - console.log("STARTED"); - }) - } stop() { @@ -546,7 +402,6 @@ class AWSProvider extends Writable { fs.writeFileSync('stream.wav', wav.toBuffer()); // this.recognizeStream.close(); - // console.log(this.recognizeStream); console.log("End of stream");