# Voice detection layout

**URL:** <https://openvidu.discourse.group/t/voice-detection-layout/192>\
**Category:** Issues developing apps\
**Tags:** v2\
**Created:** [February 25, 2020, 4:34pm UTC](https://openvidu.discourse.group/t/voice-detection-layout/192 "2020-02-25T16:34:17Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![beka.iglesias](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/beka.iglesias/32/52_2.png) [@beka.iglesias](https://openvidu.discourse.group/u/beka.iglesias)\
**Post date:** [February 25, 2020, 4:34pm UTC](https://openvidu.discourse.group/t/voice-detection-layout/192/1 "2020-02-25T16:34:17Z")

</div>

Hello,

I was implementing a voice detection layout which try to do bigger the player from the people who is speaking (using these events: [https://openvidu.io/docs/advanced-features/speech-detection/](https://openvidu.io/docs/advanced-features/speech-detection/)). I got enlarge the player for the first speaker but is not working for the second one. I am logging in the console browser and looks like not receive the events for the second user.

Is this normal os am I doing something wrong? Any advise?

Thanks in advance,

Beka

---

<div class="post-metadata">

**Author:** ![pabloFuente](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/pablofuente/32/2536_2.png) [@pabloFuente](https://openvidu.discourse.group/u/pabloFuente)\
**Post date:** [February 25, 2020, 6:29pm UTC](https://openvidu.discourse.group/t/voice-detection-layout/192/2 "2020-02-25T18:29:39Z")

</div>

Hi,

As docs says ([https://openvidu.io/api/openvidu-browser/classes/publisherspeakingevent.html](https://openvidu.io/api/openvidu-browser/classes/publisherspeakingevent.html)) speach events are only triggered for remote streams. right now.  
We can study the possiblity of also supporting them in Publishers objects.

---

<div class="post-metadata">

**Author:** ![beka.iglesias](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/beka.iglesias/32/52_2.png) [@beka.iglesias](https://openvidu.discourse.group/u/beka.iglesias)\
**Post date:** [February 25, 2020, 8:39pm UTC](https://openvidu.discourse.group/t/voice-detection-layout/192/3 "2020-02-25T20:39:40Z")

</div>

mmmmm, yeps, I understand that, but you say in this part of the doc ( [https://openvidu.io/docs/advanced-features/speech-detection/](https://openvidu.io/docs/advanced-features/speech-detection/)) : “with these events it is really easy to build a layout that can make the main speaker video the bigger one, and alternate the main view between the participants of a session as they take the floor.” I am trying to figure out why is working for the first participant and not for the second one. I mean, the second user is the remote one for the first user and his/her events are not received by any of them.

---

<div class="post-metadata">

**Author:** ![pabloFuente](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/pablofuente/32/2536_2.png) [@pabloFuente](https://openvidu.discourse.group/u/pabloFuente)\
**Post date:** [February 25, 2020, 9:18pm UTC](https://openvidu.discourse.group/t/voice-detection-layout/192/4 "2020-02-25T21:18:35Z")

</div>

All remote Streams (those owned by a Subscriber object) should trigger `publisherStartSpeaking` and `publisherStopSpeaking`. Those Streams must of course have audio tracks (property `hasAudio` to true).

If you say that in a 1:1 session one user is receiving these events for the other peer, but the other user doesn’t, then there must be something wrong with the event subscription for that specific user.

---

<div class="post-metadata">

**Author:** ![beka.iglesias](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/beka.iglesias/32/52_2.png) [@beka.iglesias](https://openvidu.discourse.group/u/beka.iglesias)\
**Post date:** [February 27, 2020, 4:22pm UTC](https://openvidu.discourse.group/t/voice-detection-layout/192/5 "2020-02-27T16:22:18Z")

</div>

I am subscribing to the publisherSpeaking events directly in the joinToSession function in the video-room.component.ts. Supposedly, the subscription apply to any user who was joining the event. I am not really sure about how to debug it. Any advise to debbug it is welcome. Thanks.

```auto
joinToSession() {
    const optionsConf = {
      publisherSpeakingEventsOptions: {
        interval: 50, // Frequency of the polling of audio streams in ms
        threshold: -50 // Threshold volume in dB
    }
    };

    this.OV = new OpenVidu();
    this.OV.setAdvancedConfiguration(optionsConf);
    this.OVScreen = new OpenVidu();
    this.OVScreen.setAdvancedConfiguration(optionsConf);
    this.session = this.OV.initSession();
    this.sessionScreen = this.OVScreen.initSession();
    this.subscribeToUserChanged();
    this.subscribeToStreamCreated();
    this.subscribedToStreamDestroyed();
    this.subscribedToChat();
    this.publisherStartSpeakingSubs();
    this.publisherStopSpeakingSubs();
    this.subscribeToEnlargeElementSignal();
    this.privateChatMessagesSignals();
    this.requestPermissionSignal();
    this.sessionDisconnectedSubs();
    this.connectionDestroyedSubs();
    this.connectToSession();
    this.updateComponent();
  }
  

```

---

<div class="post-metadata">

**Author:** ![jefersonbrz.costa](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@jefersonbrz.costa](https://openvidu.discourse.group/u/jefersonbrz.costa)\
**Post date:** [January 19, 2021, 12:15am UTC](https://openvidu.discourse.group/t/voice-detection-layout/192/6 "2021-01-19T00:15:06Z")

</div>

Hey, how did you get to work in the first time. I am having doubts about how to configure that. I need to send the speaker to the main video (bigger then other). Something like google meet.

---

<div class="post-metadata">

**Author:** ![vipin\_mishra](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/vipin_mishra/32/32_2.png) [@vipin\_mishra](https://openvidu.discourse.group/u/vipin_mishra)\
**Post date:** [January 19, 2021, 12:29pm UTC](https://openvidu.discourse.group/t/voice-detection-layout/192/7 "2021-01-19T12:29:18Z")

</div>

So whats your issues?  
Thanks  
Vipin

---

<div class="post-metadata">

**Author:** ![jefersonbrz.costa](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@jefersonbrz.costa](https://openvidu.discourse.group/u/jefersonbrz.costa)\
**Post date:** [January 19, 2021, 4:50pm UTC](https://openvidu.discourse.group/t/voice-detection-layout/192/8 "2021-01-19T16:50:06Z")

</div>

Hi @vipin_mishra no issues, I was just wondering how to implement the right way.

I already got to the session.on(‘publicherStartSpeaking’, () =\> {}), but got confuse how I get this information and set the video from this publisher as a main video for all the participants in the call.

---

<div class="post-metadata">

**Author:** ![vipin\_mishra](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/vipin_mishra/32/32_2.png) [@vipin\_mishra](https://openvidu.discourse.group/u/vipin_mishra)\
**Post date:** [January 20, 2021, 4:25pm UTC](https://openvidu.discourse.group/t/voice-detection-layout/192/9 "2021-01-20T16:25:00Z")

</div>

are you using angular or any other frameworks

---

<div class="post-metadata">

**Author:** ![jefersonbrz.costa](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@jefersonbrz.costa](https://openvidu.discourse.group/u/jefersonbrz.costa)\
**Post date:** [January 21, 2021, 1:38am UTC](https://openvidu.discourse.group/t/voice-detection-layout/192/10 "2021-01-21T01:38:49Z")

</div>

I am using React! I am using voice recognition, changing the state getting the video from subscribers and putting in the mainVideo, but the problem it is only working for one user.

---

<div class="post-metadata">

**Author:** ![vipin\_mishra](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/vipin_mishra/32/32_2.png) [@vipin\_mishra](https://openvidu.discourse.group/u/vipin_mishra)\
**Post date:** [January 21, 2021, 11:10am UTC](https://openvidu.discourse.group/t/voice-detection-layout/192/11 "2021-01-21T11:10:28Z")

</div>

In angular we layout components using that it’s easily done for Reactjs I think you have to made.  
And publisher speaking event does not work on publisher side.  
So you have to use voice or volume detection web api to change on publisher side.  
Thanks  
Vipin

---

<div class="post-metadata">

**Author:** ![jefersonbrz.costa](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@jefersonbrz.costa](https://openvidu.discourse.group/u/jefersonbrz.costa)\
**Post date:** [January 21, 2021, 2:34pm UTC](https://openvidu.discourse.group/t/voice-detection-layout/192/12 "2021-01-21T14:34:38Z")

</div>

Hi @vipin_mishra, that was what I needed. Do you know what is the best voice detection api to use? I am looking into Web Speech API, but only works in Chrome.

---

<div class="post-metadata">

**Author:** ![vipin\_mishra](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/vipin_mishra/32/32_2.png) [@vipin\_mishra](https://openvidu.discourse.group/u/vipin_mishra)\
**Post date:** [January 21, 2021, 2:39pm UTC](https://openvidu.discourse.group/t/voice-detection-layout/192/13 "2021-01-21T14:39:49Z")

</div>

Check This link [OpenVidu Docs](https://docs.openvidu.io/en/2.16.0/advanced-features/speech-detection/#audio-volume-detection) . Its worked you have to decide when volume got high at any point then you know pulisher started speaking

---

<div class="post-metadata">

**Author:** ![jefersonbrz.costa](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@jefersonbrz.costa](https://openvidu.discourse.group/u/jefersonbrz.costa)\
**Post date:** [January 21, 2021, 9:58pm UTC](https://openvidu.discourse.group/t/voice-detection-layout/192/14 "2021-01-21T21:58:28Z")

</div>

Hey, I tried that and the problem is I am getting a lot of background noise, and it is acting all the time. Do you have an example about how you did implement this?

---

<div class="post-metadata">

**Author:** ![vipin\_mishra](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/vipin_mishra/32/32_2.png) [@vipin\_mishra](https://openvidu.discourse.group/u/vipin_mishra)\
**Post date:** [January 22, 2021, 4:21am UTC](https://openvidu.discourse.group/t/voice-detection-layout/192/15 "2021-01-22T04:21:27Z")

</div>

I developed for a client but I don’t remember I have code or not available at this time.

Let me check it  
Thanks  
Vipin
