-
Notifications
You must be signed in to change notification settings - Fork 0
/
microphoneActivation.js
72 lines (62 loc) · 1.97 KB
/
microphoneActivation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
///////////////////////////////////////////////////////////////
/// WIP
/// Utilize Google-Cloud Speech API To Run NodeJS Scripts
//
// Removed But Required Package If Interested:
//"@google-cloud/speech": "^4.8.0",
//
///////////////////////////////////////////////////////////////
//
// function main(
// encoding = "LINEAR16",
// sampleRateHertz = 16000,
// languageCode = "en-US"
// ) {
// // [START micStreamRecognize]
// const recorder = require("node-record-lpcm16");
// const speech = require("@google-cloud/speech");
// const config = {
// encoding: encoding,
// sampleRateHertz: sampleRateHertz,
// languageCode: languageCode,
// DEBUG: "record",
// };
// const request = {
// config,
// interimResults: false, //Get interim results from stream
// };
// // Creates a client
// const client = new speech.SpeechClient();
// // Create a recognize stream
// const recognizeStream = client
// .streamingRecognize(request)
// .on("error", console.error)
// .on("data", (data) => {
// process.stdout.write(
// data.results[0] && data.results[0].alternatives[0]
// ? `Transcription: ${data.results[0].alternatives[0].transcript}\n`
// : "\n\nReached transcription time limit, press Ctrl+C\n"
// );
// if (data.results[0].alternatives[0].transcript.includes("cool")) {
// process.stdout.write("\n\nTrue\n\n");
// }
// });
// // Start recording and send the microphone input to the Speech API
// recorder
// .record({
// sampleRateHertz: sampleRateHertz,
// threshold: 0, //silence threshold
// recordProgram: "arecord", // Try also "arecord" or "sox"
// silence: "5.0", //seconds of silence before ending
// })
// .stream()
// .on("error", console.error)
// .pipe(recognizeStream);
// console.log("Listening, press Ctrl+C to stop.");
// // [END micStreamRecognize]
// }
// process.on("unhandledRejection", (err) => {
// console.error(err.message);
// process.exitCode = 1;
// });
// main(...process.argv.slice(2));