Created
March 11, 2022 14:49
-
-
Save DanyF-github/2c71b2a816938709269be4a44b96f5f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(() => { | |
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