New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

discord-speech-to-text

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

discord-speech-to-text - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

2

package.json
{
"name": "discord-speech-to-text",
"version": "1.1.2",
"version": "1.1.3",
"description": "A speech to text module for the discord voice implementation",

@@ -5,0 +5,0 @@ "main": "transcriber.js",

@@ -39,22 +39,28 @@ const { EndBehaviorType, VoiceReceiver } = require('@discordjs/voice');

async transcribe(buffer, raw) {
if (this.witAI_lastcallTS != null) {
let now = Math.floor(new Date());
while (now - this.witAI_lastcallTS < 1000) {
await this.sleep(100);
now = Math.floor(new Date());
try {
if (this.witAI_lastcallTS != null) {
let now = Math.floor(new Date());
while (now - this.witAI_lastcallTS < 1000) {
await this.sleep(100);
now = Math.floor(new Date());
}
}
const extractSpeechIntent = util.promisify(witClient.extractSpeechIntent);
var stream = Readable.from(buffer);
const contenttype = "audio/raw;encoding=signed-integer;bits=16;rate=48k;endian=little"
var output = await extractSpeechIntent(this.WITAPIKEY, stream, contenttype);
this.witAI_lastcallTS = Math.floor(new Date());
if (raw) return output;
if (typeof output == "object") return output;
output = output.split("\n").map((item) => item.trim()).join("");
let idx = output.lastIndexOf("}{");
let idx0 = output.lastIndexOf("}");
output = JSON.parse(output.substring(idx + 1, idx0 + 1).trim().replace(/\n/g, "").trim());
output.text = output.text.replace(/\./g, "");
stream.destroy();
return output;
} catch(e) {
console.log("Transcriber-error: ", e);
return {}
}
const extractSpeechIntent = util.promisify(witClient.extractSpeechIntent);
var stream = Readable.from(buffer);
const contenttype = "audio/raw;encoding=signed-integer;bits=16;rate=48k;endian=little"
var output = await extractSpeechIntent(this.WITAPIKEY, stream, contenttype);
this.witAI_lastcallTS = Math.floor(new Date());
if (raw) return output;
if (typeof output == "object") return output;
let idx = output.lastIndexOf("\r\n{\n");
let idx0 = output.lastIndexOf("0");
output = JSON.parse(output.substring(idx + 1, idx0).trim().replace(/\n/g, "").trim());
output.text = output.text.replace(/\./g, "");
stream.destroy();
return output;
}

@@ -61,0 +67,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc