0

im using twilio client js SDK - https://www.twilio.com/docs/voice/client/javascript/device#audio

Is there a way i can control the volume of twilio client device running on the browser?

After device.connect() i want to display a slider to control the volume, from what i see we can control audio using device.audio, but there is no example on how to set the device volume , although there is an event .audio.on('inputVolume', handler(volume))

can i implement my own audio tag and use it to control the device volume?

can i control the call volume in any other way?

NyaSol
  • 537
  • 1
  • 5
  • 21

2 Answers2

1

Twilio developer evangelist here.

The volume event that you mention is not about controlling the volume, it is a representation of the current volume of audio coming from the connection. If someone is not speaking, then volume will be low and if they are shouting it will be high.

I've not tried this, but you might be able to get the remote audio stream redirect it from the speakers, through a Web Audio API gain node and then out to the destination speakers. You could then control the gain node to control the volume.

philnash
  • 70,667
  • 10
  • 60
  • 88
0

Thank you @philnash, I've tried to control the audio using the Web Audio API with no success, Because we are running an internal system on our users computers i can control chrome sound using python like so: How do I change the volume of Chrome using Selenium

from __future__ import print_function
from pycaw.pycaw import AudioUtilities, ISimpleAudioVolume


sessions = AudioUtilities.GetAllSessions()
for session in sessions:
    volume = session._ctl.QueryInterface(ISimpleAudioVolume)
    if session.Process and session.Process.name() == "chrome.exe":
        volume.SetMasterVolume(0.5, None)

So each time the user wants to set the volume im emitting an event to a flask server running on the user machine, this is not a valid solution for controlling the Twilio device volume of course, since im setting the chrome volume and not the device, but it works for our needs, thank you.

NyaSol
  • 537
  • 1
  • 5
  • 21