Skip to content

Instantly share code, notes, and snippets.

@DanyF-github
Created March 11, 2022 14:49
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 DanyF-github/2c71b2a816938709269be4a44b96f5f1 to your computer and use it in GitHub Desktop.
Save DanyF-github/2c71b2a816938709269be4a44b96f5f1 to your computer and use it in GitHub Desktop.
(() => {
if (isPublishing && publisher) {
const audioTrack = publisher.getAudioSource();
const stream = new MediaStream();
stream.addTrack(audioTrack);
const AudioContext = window.AudioContext;
const context = new AudioContext();
const source = context.createMediaStreamSource(stream);
const id = roomName;
const connectionConfig = {
id,
insightTypes: ['action_item', 'question'],
source: source,
config: {
meetingTitle: 'My Test Meeting ' + id,
confidenceThreshold: 0.5, // Offset in minutes from UTC
encoding: 'LINEAR16',
languageCode: 'en-US',
speaker: {
// Optional, if not specified, will simply not send an email in the end.
userId: '', // Update with valid email
name: preferences.userName || uuidv4(),
},
handlers: {
/**
* This will return live speech-to-text transcription of the call.
*/
onSpeechDetected: (data) => {
if (data) {
if (data.user.name !== preferences.userName) {
setCaptions(data.punctuated.transcript);
setName(data.user.name);
} else {
setMyCaptions(data.punctuated.transcript);
}
}
},
},
};
const start = async () => {
try {
const stream = await symbl.createStream(connectionConfig);
streamRef.current = stream;
await stream.start();
conversationId.current = await stream.conversationId;
preferences.conversationId = conversationId.current;
} catch (e) {
console.log(e);
}
};
start();
}
}, [
isPublishing,
roomName,
preferences,
publisher,
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment