Closed vinay047 closed 4 years ago
Can you share how you’re importing the package?
Hi @qasim9872
Thanks for replying , appreciate for your help. In this way i am declaring the package, as i m working on the nodejs.
const AwsTranscribe = require('aws-transcribe'); const StreamingClient = require('aws-transcribe');
Can you try to import them in this way:
const { AwsTranscribe, StreamingClient, TranscribeException } = require("aws-transcribe")
Hi @qasim9872
Thanks for reply ,i tried the way you suggested and its works as well and i really thankful to it, but after that impleamentaion i am getting the following error TypeError: yourstream.pipe is not a function .
Actuall i m trying to pass the twilio stream to the "transcribeStream" in the following way,
var yourStream = msg.media.payload yourStream.pipe(transcribeStream)
msg.media.payload will contain the media stream which we will get from the twilio. not sure where i am making mistake could you please provide some help in this.
Thanks is advance!
Hi @vinay047
That is happening because the pipe function is provided by a node js stream. From the looks of it, msg.media.payload is not a stream and is simply an audio chunk.
There are two ways to approach this. The first one is that you wrap the incoming twilio messages in a stream. If you are using a websocket server, there are already packages which do this. Afterwards, you’ll be able to directly pipe the audio chunks to aws transcribe.
The second option is bypassing the pipe. You can do that by calling transcribeStream._write(msg.media.payload). This can be a quick fix but in the long run, I would suggest streams are a better way to deal with streaming.
Let me know how it goes
Thanks for your prompt reply @qasim9872
I tried the second approach that you suggested and i am getting the following error TypeError: Cannot read property '_write' of undefined.
Thanks in advance!
Hey, take a look at this example. It sort of does something similar to what you need.
Thanks for sharing the link, Just one quick question , we are creating the two different websocket in our application, one we creating on the frontend to showase the live text to the UI and another we are creating on the backend to capture some of the events. We are using ws package not the socket.io package, so can we achieve same thing wgat is in the link using ws package ?
Hey, yes you can achieve the same. Just for clarification, are you using two separate web sockets?
You can achieve the same with ws package. Instead of emitting using a named event, with ws package you would simply send a message from the frontend and process it similarly on the backend.
Can you share a minimum example of your setup and I can try to help?
Hi @qasim9872 ,
Sorry for responding late , please find the code snippet example in the attachment.
This is the reference URL https://www.twilio.com/blog/live-transcribing-phone-calls-using-twilio-media-streams-and-google-speech-text In this they are using the Twilio with GCP speech-to-text , and we have the same setup as mention in the reference link, and it works for us , can we achieve the same things using the AWS Transcribe.
Hey, thanks for sharing. I'll be closing the issue as you were able to get the transcription to work. Let me know if there are any other issues
Hi @qasim9872 ,
I think you have some misunderstanding the issue is still persist with the AWS Transcribe , i just give you the reference of GCP speech to text as it has same configuration what we have but we need output with the AWS-Transcribe not with GCP, Could you please re-open the issue.
Note:- We need live transcription with the AWS-Transcribe not with GCP speech to text.
Hi @qasim9872 ,
Thank you re-opening the issue, as you said, I already share the code sample with you, Could provide some input on this issue.
Note :- transcribe.txt is the example that i am using in my code base
Hi @vinay047
I have updated the example available on the Twilio blog. You can find it here, https://gist.github.com/qasim9872/06173159aa594623004724c080e10736
Let me know if this works for you?
Thanks
Hi @qasim9872 ,
Thanks for the response. I made the change as per the link you have given, I am getting the following error
C:\Users\Administrator\Documents\testaws\node_modules\aws-transcribe\dist\StreamingClient.js:79 cb(); ^ TypeError: cb is not a function at StreamingClient._write (C:\Users\Administrator\Documents\testaws\node_modules\aws-transcribe\dist\StreamingClient.js:79:9)
Hi @vinay047
Can you try again, I have just added a fix for that.
Thanks
Hi @qasim9872 ,
I ran it again, but getting the same issue TypeError: cb is not a function ,So do i need to re-install the aws-transcribe package. to see the changes?
Hey,
I updated line 102 in the gist I shared. it's this one:
recognizeStream._write(mulawToPcm(msg.media.payload), null, () => {});
Thanks
Hi @qasim9872,
I change the particular line that u haven mentioned ,I am not getting any syntax error now , only the output what i am getting is this:- recognizing text: Mm mm mm mm mm mm mm mm mm mm mm Mm Mm mm mm. recognizing text: Mm mm mm mm mm mm mm mm mm mm mm mm Mm Mm mm mm.
Whatever we speaking we are just getting Mm mm text in our screen not the actual text , Could you please help us out in this issue.
Thanks you.
Hi @qasim9872 ,
Waiting for your response, it would be great help if you give us some feedback.
Thanks.
Hi @vinay047,
can you check and make sure the sample rate you're specifying to aws transcribe is 8000?
This is Rahul here... Okay. @qasim9872 I am from @vinay047 team... yes we are specifying sampling rate as 8000
Hi @qasim9872 ,
Thanks for your response ,what @rrahul4 is saying is absolutely correct we are using the sample rate as 8000.
Thanks.
Hi @vinay047 & @rrahul4,
I have updated the gist here: https://gist.github.com/qasim9872/06173159aa594623004724c080e10736
The issue was that the audio payload from Twilio was base64 encoded, so before it could be passed to amazon, we had to convert it to a raw buffer.
Thanks
Hi @qasim9872 ,
Thank you so much transcribe is working now and the updated gist you have provided is really us help to resolve that issue . and I am really thankfully to you.
I am closing this issue. Thanks
Happy to help. You’re welcome
We are trying to use Aws Transcribe service to pass the twilio stream for real time transcription, we are using this given snippet to get live transcription, when we getting the TypeError: AwsTranscribe is not a constructor Error. We have install the AWS Transcribe library but still we are getting the same issue. Kindly help me out.
**const client = new AwsTranscribe({ // if these aren't provided, they will be taken from the environment accessKeyId: "A*****J", secretAccessKey: "l****t", })**
Thanks.