Skip to content

Instantly share code, notes, and snippets.

@moonexpr
Created June 7, 2023 19:06
Show Gist options
  • Save moonexpr/b0e00152ec424224db1a3f996022b14f to your computer and use it in GitHub Desktop.
Save moonexpr/b0e00152ec424224db1a3f996022b14f to your computer and use it in GitHub Desktop.
Utility functions for voice.google.com
var S = {
// ================================================================================
// 1: List of all audio elements.
// document.getElementsByTagName('audio');
// --------------------------------------------------------------------------------
// HTMLCollection { 0: audio, 1: audio, 2: audio, 3: audio , length: 4 }
// 0: <audio loop="" gv-id="US_busy_tone">
// 1: <audio loop="" gv-id="US_outbound_ring">
// 2: <audio loop="" gv-id="inbound_ring">
// 3: <audio gv-id="end_call">
// length: 4
// ================================================================================
discover: () => {
T.collections =
{
audio : Array.from(document.getElementsByTagName('audio'))
};
T.sfx = {
busy : S.find_audio('US_busy_tone'),
outbound : S.find_audio('US_outbound_ring'),
inbound : S.find_audio('inbound_ring')
};
},
find_audio: (id) =>
// @param id string `gv-id` of the audio element.
// @return element?
{
return document.querySelector(`audio[gv-id=${id}]`);
},
audio_index: () =>
{
console.log("Index of audio elements:");
console.log(G.collections.audio);
}
}
var T = {
collections: {},
sfx: {},
}
var E = {
stop_ringing: () =>
{
S.discover();
if (undefined == T.sfx.inbound)
{
console.warn('Inbound audio element is missing?')
S.audio_index();
return
}
}
}
var A = { }
var M = { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment