MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / main

Function main

speech/createRecognizer.v2.js:21–54  ·  view source on GitHub ↗
(recognizerId, projectId)

Source from the content-addressed store, hash-verified

19// description: Create a speech recognizer in Speech-to-Text v2
20
21async function main(recognizerId, projectId) {
22 // [START speech_create_recognizer]
23
24 /**
25 * TODO(developer): Uncomment the following lines before running the sample.
26 */
27 // const recognizerId = 'a unique name in your project for this recognizer';
28 // const projectId = 'your Google Cloud project ID';
29
30 // Imports the Google Cloud client library
31 const speech = require('@google-cloud/speech').v2;
32
33 async function createRecognizer() {
34 // Instantiate the client
35 const client = new speech.SpeechClient();
36
37 const recognizerRequest = {
38 parent: `projects/${projectId}/locations/global`,
39 recognizerId: recognizerId,
40 recognizer: {
41 languageCodes: ['en-US'],
42 model: 'latest_long',
43 },
44 };
45
46 const operation = await client.createRecognizer(recognizerRequest);
47 const recognizer = operation[0].result;
48 const recognizerName = recognizer.name;
49 console.log(`Created new recognizer: ${recognizerName}`);
50 }
51
52 await createRecognizer();
53 // [END speech_create_recognizer]
54}
55
56exports.createRecognizerV2 = main;

Callers

nothing calls this directly

Calls 1

createRecognizerFunction · 0.85

Tested by

no test coverage detected