Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to implement in angular 8. #5

Open
Sathyamurthy-tammina opened this issue Mar 23, 2021 · 0 comments
Open

Trying to implement in angular 8. #5

Sathyamurthy-tammina opened this issue Mar 23, 2021 · 0 comments

Comments

@Sathyamurthy-tammina
Copy link

I have been trying to use this component in angular(version mentioned in the title). I did follow the following steps:
1, npm install --save obvi-component
2. I have pasted the html in the app component html

<script src="node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
<voice-button id="voice-button" cloud-speech-api-key="YOUR_API_KEY" autodetect></voice-button>

<script type="module">

  import './node_modules/obvi/voice-button.js';

  var voiceEl = document.querySelector('voice-button'),
    transcriptionEl = document.getElementById('transcription');

  // can check the supported flag, and do something if it's disabled / not supported
  console.log('does this browser support WebRTC?', voiceEl.supported);

  voiceEl.addEventListener('mousedown', function(event){
    transcriptionEl.innerHTML = '';
  })

  var transcription = '';
  voiceEl.addEventListener('onSpeech', function(event){
    transcription = event.detail.speechResult;
    transcriptionEl.innerHTML = transcription;
    console.log('Speech response: ', event.detail.speechResult)
    transcriptionEl.classList.add('interim');
    if(event.detail.isFinal){
      transcriptionEl.classList.remove('interim');
    }
  })

  voiceEl.addEventListener('onStateChange', function(event){
    console.log('state:',event.detail.newValue);
  })

</script>

and then did ng serve. I get net work error as follows:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant