Skip to content

Instantly share code, notes, and snippets.

@savelee
Created March 11, 2020 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save savelee/73af0549a2cbdc4bd945b90ea2fcfc7c to your computer and use it in GitHub Desktop.
Save savelee/73af0549a2cbdc4bd945b90ea2fcfc7c to your computer and use it in GitHub Desktop.
Speech Adaptation in Dialogflow
const uuid = require('uuid');
const df = require('dialogflow').v2beta1;
const sessionId = uuid.v4();
const sessionClient = new df.SessionsClient();
const sessionPath = sessionClient.sessionPath(projectId, sessionId);
let request = {
session: sessionPath,
queryInput: {
audioConfig: {
sampleRateHertz: 16000,
encoding: 'AUDIO_ENCODING_LINEAR_16',
languageCode: 'en-US',
speechContexts: [
{
phrases: [
'mail',
'email'
],
boost: 20.0
}
]
},
singleUtterance: singleUtterance
}
}
request.inputAudio = audio;
const responses = await sessionClient.detectIntent(request);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment