<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Yash Jaiswal on Medium]]></title>
        <description><![CDATA[Stories by Yash Jaiswal on Medium]]></description>
        <link>https://medium.com/@yashjais?source=rss-4816733e17b5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*oW4GHd7M3nswAiIqrUJkPw.jpeg</url>
            <title>Stories by Yash Jaiswal on Medium</title>
            <link>https://medium.com/@yashjais?source=rss-4816733e17b5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 03:34:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yashjais/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[An Overview & Running code Example of AWS Transcribe(Live)]]></title>
            <link>https://yashjais.medium.com/an-overview-running-code-example-of-aws-transcribe-live-a74e79d28b12?source=rss-4816733e17b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/a74e79d28b12</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[aws-sdk]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[amazon-transcribe]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <dc:creator><![CDATA[Yash Jaiswal]]></dc:creator>
            <pubDate>Sun, 30 Oct 2022 07:22:45 GMT</pubDate>
            <atom:updated>2022-10-30T08:06:52.957Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://aws.amazon.com/transcribe/">AWS Transcribe</a> is a highly scalable, on-demand speech-to-text transcription service. It is capable of analyzing multiple audio formats from files stored in S3 and provides accurate transcription, including timestamps for each word. AWS Transcribe can also operate on streaming audio, providing a stream of transcribed text in real time. Moreover, as part of the <a href="https://aws.amazon.com/free/">AWS Free Tier</a>, you can get started with Amazon Transcribe for free. The Amazon Transcribe Free Tier is available to you for 12 months, starting from the date on which you create your first transcription request. You can check out the details <a href="https://aws.amazon.com/transcribe/pricing/">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*LlZzll0tcZw_HapYP5Yg6A.jpeg" /><figcaption>Amazon Transcribe</figcaption></figure><p>In this article, we’ll be looking at an example of the transcription of speech-to-text in <strong>real-time</strong>. Moreover, I’ll also be writing an article on how to use <strong>Amazon Cognito</strong> using the Identity pool to get a temporary set of credentials to use in transcribe services, so keep an eye out for that! For now, we’ll be creating transcribe service in our AWS Account, and we’ll be using React and AWS software development kit in this example.</p><p>Let’s take a dive into the code and see how to get things done. First things First, let’s talk about getting the live speech to text. One prerequisite required to run the code in this article is that you should have access to an<a href="https://aws.amazon.com/console/"> AWS</a> account.</p><p>Here’s the <a href="https://github.com/yashjais/AWS-Audio-Transcribe/blob/main/src/App.js"><strong>code</strong></a> for spinning up the Transcribe service. Let’s go through it once.</p><blockquote>constructor() { <br> super(); <br> this.state = {<br> isRecordingStopped: true,<br> };<br> this.micStream = React.createRef(); <br> this.speechToText = React.createRef();<br>}</blockquote><p>Initializing a variable in the state, and a couple of variables with the React.createRef.</p><p>Clicking on the ‘start recording’ will trigger the following function.</p><blockquote>startRecording = async () =&gt; {<br> this.setState({ isRecordingStopped: false }); <br> const audio = await navigator.mediaDevices.getUserMedia({<br> audio: true,<br> video: false,<br> });<br> let micStream = null;<br> micStream = new MicrophoneStream();<br> micStream.setStream(audio); this.micStream = micStream;<br> this.awsTranscribe(micStream);<br>};</blockquote><p>The above lines of code will instantiate the new microphone stream for us and we can pass this stream to a generator function which can again be passed to aws-sdk to get the text from the speech. Let’s go through the <em>awsTranscribe </em>function to see the magic where we get the text from speech.</p><blockquote>awsTranscribe = async (event) =&gt; { <br>try {<br> const _this = this;<br> const MAX_AUDIO_CHUNK_SIZE = 48000;<br> const audioStream = async function* () {<br> for await (const chunk of event) {<br> if (chunk.length &lt;= MAX_AUDIO_CHUNK_SIZE) { <br> yield {<br> AudioEvent: { AudioChunk: _this.pcmEncodeChunk( chunk, ), }<br> };<br> }<br> }<br>};<br>const credentials = { <br> accessKeyId: ‘’, <br> secretAccessKey: ‘’,<br>}; <br>const transcribeClient = new TranscribeStreamingClient({<br> region: ‘us-east-1’,<br> credentials,<br>});<br>this.transcribeClient = transcribeClient;<br>const command = new StartStreamTranscriptionCommand({<br> LanguageCode: ‘en-US’,<br> MediaEncoding: ‘pcm’,<br> MediaSampleRateHertz: 44100,<br> AudioStream: audioStream(),<br>});<br>const data = await transcribeClient.send(command);<br>let speechToText = ‘’; <br>for await (const evt of data.TranscriptResultStream) {<br> for (const result of evt.TranscriptEvent.Transcript.Results || []) {<br> if (result.IsPartial === false) {<br> const noOfResults = result.Alternatives[0].Items.length;<br> for (let i = 0; i &lt; noOfResults; i++) {<br> speechToText += `${result.Alternatives[0].Items[i].Content} `;<br> this.speechToText.current = speechToText; <br> console.log(‘speech to text’, speechToText);<br> }<br> }<br>}<br>}<br>} catch (err) {<br> console.log(‘err’, err); <br> }<br>};</blockquote><p>We’re passing our stream event to a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*">generator function</a>, which in turn is being passed to the `aws-sdk`, which gives us a text from our speech. The above code is pretty straightforward forward where we’re instantiating a new object from <em>TranscribeStreamingClient</em> and passing an object in it which is instantiated from <em>StartStreamTranscriptionCommand </em>class<em>. <br></em>We’re passing languageCode, mediaEncoding, mediaSampleRate, and audioStream to StartStreamTranscriptionCommand to make our object. We can pass a different number of options to this class. You can read more about it <a href="https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartStreamTranscription.html">here</a>.</p><p>Now the only thing that is remaining to get the speech from text is how to get the credentials. Here’s a one-way step-by-step procedure from which you can get the credentials that can be used to get a text from speech. <br>&gt; We’ve to open up an account with <a href="https://aws.amazon.com/">AWS</a>.<br>&gt; Create an <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html">IAM</a> user.<br>&gt; Give access to Transcribe service to that IAM user which you just created.<br>&gt; Use these credentials in the above code to get a speech from the text!</p><p>That’s it, folks! Hope you’ve learned something new today. Have a good day.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a74e79d28b12" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript - Pass By Reference]]></title>
            <link>https://yashjais.medium.com/javascript-pass-by-reference-5e2b8f2e382a?source=rss-4816733e17b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e2b8f2e382a</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[pass-by-value]]></category>
            <category><![CDATA[pass-by-reference]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[javascript-development]]></category>
            <dc:creator><![CDATA[Yash Jaiswal]]></dc:creator>
            <pubDate>Sat, 17 Apr 2021 11:30:19 GMT</pubDate>
            <atom:updated>2021-04-17T11:30:19.992Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve been coding in JavaScript for the past one-plus year. And this concept always seems a little complicated to me. So let’s dive into the basics of what is passed by reference in JavaScript. And we’ll look into some examples to understand it a little better.</p><p>You’ll find abundant of articles/tutorials which talk about what is pass by value and what is pass by reference, but in this article, I’ll show some of the examples of passed by reference, which you can try yourselves later on.</p><p>So what is passed by reference?</p><p>To understand this term, first, we need to know about Data Structures in JS.</p><p>Broadly there are two types of Data Structures in JS, that are Primitive types and Object types. You can read about them <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures">here</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cd84d46668d577aa2be00c1ecb4cbe0f/href">https://medium.com/media/cd84d46668d577aa2be00c1ecb4cbe0f/href</a></iframe><p>When we assign a variable of Primitive type, it is basically passed by value, but when we assign a variable of Object type, it is passed by reference. Let’s clear this up with some examples.</p><p>This is an example of pass by value</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4375a27eebf93e3654002c159a3ce98e/href">https://medium.com/media/4375a27eebf93e3654002c159a3ce98e/href</a></iframe><p>In this example, we’re first declaring and initializing a variable a. Then we&#39;re assigning that variable to b. But when we do any modification on a, b doesn’t get modified and this is what pass by value means. Now, let’s move to the main part of this article.</p><p>Let’s see an example of pass by reference</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ff8deaa19d8545e95a37d1f496c8ab9c/href">https://medium.com/media/ff8deaa19d8545e95a37d1f496c8ab9c/href</a></iframe><p>In the above example, we’re working with both arrays and objects since both the DS come under the category of Object types in JS.</p><p>Let’s talk about array in this example, we’re first declaring and initializing a variable x, and then we’re assigning it to y.</p><p>Now when we modify the index of the variable x and console log out x and y, we see a change in y as well.<br>This is because Object types are passed by reference, and when we modify the x, y also gets modified. This is because JS didn’t just make a new copy which was the case in pass-by-value, but it is just assigning the memory address to y of the variable x.<br>This is what happens with the Object/hash as well. JS just assigns the reference to the variable and doesn’t make the new copy. So whenever we do modification in the original variable, it will reflect in the copied array of object/hash.<br>Though there are ways to make a copy of a variable which is not referencing the original variable like concat and spread(just syntactic sugar for concat in ES-6), but this is out of scope of this article. Let me know if you want to have an article on that too!</p><p>Thanks for reading! Hope you understood the concept of passed by reference. If you’ve any queries/suggestion/feedback, feel free to contact me at jais.yash01@gmail.com.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e2b8f2e382a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>