<?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 Madhura Gore on Medium]]></title>
        <description><![CDATA[Stories by Madhura Gore on Medium]]></description>
        <link>https://medium.com/@madhura-gore?source=rss-8e2533f31df1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*8Lie1XTud79fK1nIbGjVKw.jpeg</url>
            <title>Stories by Madhura Gore on Medium</title>
            <link>https://medium.com/@madhura-gore?source=rss-8e2533f31df1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 19:15:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@madhura-gore/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[Angular Material Stepper With Pagination]]></title>
            <link>https://madhura-gore.medium.com/angular-material-stepper-with-pagination-b9e1b091b8f6?source=rss-8e2533f31df1------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9e1b091b8f6</guid>
            <category><![CDATA[angular-material]]></category>
            <category><![CDATA[wizard-workflow]]></category>
            <category><![CDATA[custom-stepper]]></category>
            <category><![CDATA[stepper-with-pagination]]></category>
            <dc:creator><![CDATA[Madhura Gore]]></dc:creator>
            <pubDate>Wed, 31 Mar 2021 08:04:54 GMT</pubDate>
            <atom:updated>2021-03-31T08:04:54.828Z</atom:updated>
            <content:encoded><![CDATA[<p>Angular Material’s stepper provides a wizard-like workflow by dividing content into logical steps. This type of workflow design pattern is commonly used in UI when we have long forms which can be broken down into groups of similar form fields or when there’s an activity having sequential flow of logic. For example, on an E-commerce website, you might encounter a step by step process of placing your order at the time of checkout, where step 1 asks for your name and address, step 2 contains review of cart items and step 3 asks for the payment details.</p><p>For a quick overview of Angular Material Stepper, you can check this link:</p><p><a href="https://material.angular.io/components/stepper/overview">Angular Material</a></p><h4><strong>TL;DR? Check out the working demo over here:</strong></h4><p><a href="https://angular-mat-stepper-paginator.stackblitz.io/">https://angular-mat-stepper-paginator.stackblitz.io</a></p><p><strong>The problem:</strong> While working on a similar use case where we had a long form of around 8–10 steps, we wanted to use the horizontal stepper along with a paginator. But with the horizontal stepper, the step titles would become congested when showing all of them together in the view at the same time. (And of course, you wouldn’t want to include that nasty horizontal scrollbar on your page!) Something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GtFTKdrB5n2vjnOb" /></figure><p>For this reason, we needed something like a paginator which can move back and forth between the steps and the stepper would look more appealing. Currently, there is no support from Angular Material with such kind of customization and there are several requests to include this functionality.</p><p>There’s an option of using vertical orientation of the stepper, but here’s how it looks like when there are large number of steps:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/0*E3L3_vWy9gcTj6tn" /></figure><p>As you can see, there’s much of a blank space on the page when the steps are in collapsed form and we didn’t find this appealing for our purpose.</p><p><strong>The solution: </strong>So, coming back to our horizontal stepper, we did work on a solution and were able to overcome the problem! Phew!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*YZDO7LSS3TTRqnwECH4Vpw.gif" /></figure><p>There isn’t any direct approach to show / hide steps in the mat-stepper. That’s why when we try applying ngIf / hidden to mat-step, it removes the step from the view. For example, if you have 8 steps and try to hide the first 2 steps using ngIf, it takes as if there are a total 6 steps and re-assigns the step indexes of each step. (Index of step 3 becomes 1, that of step 4 becomes 2 and so on up to step 6). To fix this behaviour, the steps which should not be visible in the view need to have a display as “none” and this can be achieved by manipulating the DOM through template reference along with pagination logic.</p><p>We’ll talk about different approaches we can have for navigation and pagination in the stepper. The main logic revolves around 2 variables — min and max steps we want to display in the view at any given point.</p><h4><strong>Solution 1:</strong></h4><p>Consider you have a total of 8 steps and the maximum number of steps that you want to show on the page at any time is 4. You want your back and next buttons to navigate through each step of the stepper.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QQSfwL5fTVU7O2U7" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*10i0PmNNf0rKOVwm" /></figure><p>This will simply bring 4 steps into view at any given time. At the start, you’ll have steps 1–4 into view. To go from step 1 to 4, you’ll click on next arrow button 3 times and if you click on next button after reaching step 4, the steps 2–5 will come into view as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KOFh19iW33PSJUk-" /></figure><p>So at any given time, you have a frame of 4 steps which you’re moving from step to step. For example, 1–4, 2–5, 3–6, 4–7 or 5–8. This solution would only act as a navigator from step to step and we aren’t doing any pagination work over here.</p><h4><strong>Solution 2:</strong></h4><p>In this type, we have the arrow buttons acting as a navigator as well as a paginator. Also, the frame of 4 steps will now look something like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bUoF1l09xENUULVX" /></figure><p>The frames over here act like pages. You’ll have pages of steps 1–4 and steps 5–8 (9–12 and so on if you have more steps). The obvious question over here would be what if we want a frame of 3 steps? In this case, our maximum steps in view would remain 3 and to maintain evenness, we’ll have page frames like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qkdQbBPQWyDaW1OO" /></figure><p>For the last frame, as can be seen above, the frame size still remains 3 and without disturbing the consistency of user view, we can show the steps into view.</p><p>Continuing with our 4 steps example,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UXyfVzqChuCvvi3l" /></figure><p>At the start, To go from step 1 to 4, you’ll click on next arrow button 3 times and when you click on next arrow button after step 4, you’ll not only have a new single step, but the page frame would get changed to steps 5–7:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Dsvym4Tz_0Xot7Yc" /></figure><p>At any given time, we’ll have either steps 1–4 or steps 5–7 into view in this approach.</p><h4><strong>Solution 3:</strong></h4><p>The page frames from solution 2 remain the same in this approach, i.e. we’ll have steps 1–4 or 5–7 into view at any given point. But in solution 2, if you want to navigate from step 1 to step 5, you’ll first need to navigate through steps 1, 2, 3, 4 and then only step 5 would be visible. Solution 3 would help you directly navigate from step 1 to step 5, i.e. you can change the page without going through individual steps in between. For that, we’ll separate the navigation and pagination into 2 parts — the 2 arrows (forward and backward) will act as paginators and the 2 action buttons (Back and Save and Continue) will act as navigators. This would be better from the usability perspective where you’re saving the user actions if the user wants to check what’s there in the next steps in the form.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dtn6uOspdFLnUvyR" /></figure><h4><strong>Rendering Logic:</strong></h4><p>Depending on your page frame and the min and max step indexes you want to show in the view, you’ll just display the steps which fit into the min — max step range and for other steps, as mentioned above, we’ll set the display to “none”. Same goes for the horizontal lines joining the steps.</p><p>So, the above summary was the logic behind the stepper with paginator that we’ve implemented. You can refer to the Angular code over here:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-mat-stepper-paginator%3Fembed%3D1&amp;display_name=StackBlitz&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Fangular-mat-stepper-paginator&amp;image=https%3A%2F%2Fc.staticblitz.com%2Fassets%2Ficon-03bbb9acbba813917725387f46e5df03a95d232be240e910ce5f946a973b3f86.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=stackblitz" width="745" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/bbd08bfa52cbce639a0417651cd4ae0c/href">https://medium.com/media/bbd08bfa52cbce639a0417651cd4ae0c/href</a></iframe><h4><strong>Happy Coding!</strong></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9e1b091b8f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to get rid of Longtime elapsed without audio and Resource exhausted error in Google Speech to…]]></title>
            <link>https://madhura-gore.medium.com/how-to-get-rid-of-longtime-elapsed-without-audio-and-resource-exhausted-error-in-google-speech-to-a471c47fdec?source=rss-8e2533f31df1------2</link>
            <guid isPermaLink="false">https://medium.com/p/a471c47fdec</guid>
            <category><![CDATA[m3u8]]></category>
            <category><![CDATA[speech-recognition]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Madhura Gore]]></dc:creator>
            <pubDate>Fri, 29 Nov 2019 18:39:25 GMT</pubDate>
            <atom:updated>2019-11-29T18:39:25.780Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>How to get rid of Longtime elapsed without audio and Resource exhausted error in Google Speech to Text for m3u8 video stream</strong></h4><figure><img alt="Speech to Text" src="https://cdn-images-1.medium.com/max/556/1*SvB6VPtPaU70dskNNVxLXw.png" /></figure><p>This post is a part of “Generating transcripts for an m3u8 video stream using Google Cloud Speech to Text” series. It would be better if you go through the previous post first:</p><p><a href="https://medium.com/@rushikeshsp25/generating-transcripts-for-an-m3u8-video-stream-using-google-cloud-speech-to-text-f59254b9674">Generating transcripts for an m3u8 video stream using google cloud speech to text</a></p><p>Note: We assume you know the basics of Google Cloud Speech to Text and have already set up a project on Google Cloud Platform and have activated a service account. If not, see <a href="https://cloud.google.com/speech-to-text/docs/quickstart">Speech to Text Quickstart</a>.</p><p>Let’s first understand what these errors mean. Here’s a quick overview for both of these errors:</p><ul><li><strong>Error 11: </strong>This error occurs because of following reasons:</li></ul><ol><li><strong>Long time elapsed without audio:</strong> This means there was no audio sent to the Google Cloud Speech to Text <a href="https://cloud.google.com/speech-to-text/docs/streaming-recognize"><em>streamingRecognize</em> </a>stream (will be referred as recognizeStream) for a particular duration of time, 10 seconds to be precise. Here, “no audio” does not mean silence. In case of speech processing, silence is also considered to be a form of audio and hence even if you send some continuous silence to the stream, error 11 will not occur. For eg, if you write chunks of 0’s to the stream, this error won’t occur. Let me explain this with an example. Suppose you write some audio chunks to recognizeStream at time 12.01, 12.02, and there’s absolutely no data coming from your audio stream till 12.15, so the next audio chunk getting written to recognizeStream is at 12.15, this is the case where the “no audio” duration is greater than 10 seconds, and you’ll get error 11 — long time elapsed without audio.</li><li><strong>Exceeded maximum allowed stream duration of 305 seconds:</strong> The current maximum duration (streamingLimit) for which recognizeStream can be open is ~5 minutes, 305 seconds to be precise, so if a stream is open for more than 305 seconds, this error occurs. So, we have to make sure that the recognizeStream will be closed properly when this time limit is reached and a new stream has to be created for further processing.</li></ol><ul><li><strong>Error 8 (Resource exhausted):</strong> As the name suggests, when content/request limits are exceeded, this error is thrown. Usage limit for requests/per 60 seconds is 900 and 480 hours of audio processing is allowed per day. You can refer to <a href="https://cloud.google.com/speech-to-text/quotas"><em>Quotas &amp; limits</em></a> page of Google Speech to Text. In our case, the data which was coming from the m3u8 stream was of variable streaming rate. Initially we were writing chunks directly into recognizeStream<em> </em>and hence a large amount of data was getting written to the stream in a short interval of time. Hence we controlled the data being written into the Google Cloud Speech to Text stream through a buffer and sent these controlled audio chunks to speech to text.</li></ul><p><strong>Approach for controlling audio data:</strong></p><ol><li>Store the audio chunks coming into the transform method of Node.js stream to an audio buffer.</li><li>At a periodic time interval, remove a certain amount of audio chunks from this buffer and write these removed chunks into recognizeStream.</li><li>You can have a fixed size of audio chunks to be removed from the buffer if the data coming from your m3u8 stream is at a constant rate. Since the audio data coming from our m3u8 stream was of variable rate, based on that rate, we considered 4 slabs of streaming rate.</li></ol><pre>let out_write_size = {<br>    high: 160000,<br>    medium: 80000,<br>    low: 20000,<br>    very_low: 1024<br>};</pre><p>So, at a particular time, we will check the audio buffer (this will give us an idea of current rate at which audio data is coming), remove the chunks of audio in that particular slab and then write these chunks to recognizeStream. (Higher rate means we will remove the high slab, lower rate means we will remove the low slab and so on..)</p><h4>Node.js Code:</h4><pre>//imports<br>const ffmpeg = require(&#39;fluent-ffmpeg&#39;);<br>const {<br>    Transform<br>} = require(&#39;stream&#39;);<br>const fs = require(&#39;fs&#39;);<br>//google speech to text<br>const speech = require(&#39;@google-cloud/speech&#39;);<br>//creates a speech client<br>const speechClient = new speech.v1p1beta1.SpeechClient();</pre><pre>let recognizeStream, timeout;<br>let streamingLimit = 210000 //3.5 minutes</pre><pre>let configurations = {<br>    config: {<br>        encoding: &#39;FLAC&#39;,<br>        sampleRateHertz: 48000,<br>        languageCode: &#39;en-US&#39;,<br>        model: &#39;default&#39;,<br>        audioChannelCount: 2,<br>        enableWordTimeOffsets: true,<br>    },<br>    interimResults: true,<br>};</pre><pre>let out_write_size = {<br>    high: 160000,<br>    medium: 80000,<br>    low: 20000,<br>    very_low: 1024<br>}; </pre><pre>//link to your m3u8 stream<br>let livestream_endpoint = &#39;https://&lt;your_m3u8_stream...&gt;.m3u8&#39;; <br>let audio_buffer = null;<br>const empty_buffer = Buffer.alloc(1, 0);<br>let isFirstProgress = true;<br><br>function startStream() {<br>    console.log(&quot;started recognition stream &quot;);<br>    recognizeStream = speechClient<br>        .streamingRecognize(configurations)<br>        .on(&#39;error&#39;, (err) =&gt; {<br>            console.log(err);<br>        })<br>        .on(&#39;data&#39;, (stream) =&gt; {<br>            speechCallback(stream);<br>        });<br>    //restarting stream every 3.5 mins for infinite streaming<br>    timeout = setTimeout(restartStream, streamingLimit);<br>}<br><br>function speechCallback(stream, incoming_which_stream) {<br>    let stdoutText = stream.results[0].alternatives[0].transcript;<br>    if (stream.results[0] &amp;&amp; stream.results[0].isFinal) {<br>        console.log(&quot;Final Result : &quot;, stdoutText);<br>        fs.appendFile(&#39;transcripts.txt&#39;, stdoutText, (err) =&gt; {<br>            if (err)<br>                console.log(err);<br>        });<br>    } else {<br>        console.log(&quot;Interim Result : &quot;, stdoutText);<br>    }<br>}<br><br>function restartStream() {<br>    if (recognizeStream) {<br>        recognizeStream.removeListener(&#39;data&#39;, speechCallback);<br>        recognizeStream.destroy();<br>        recognizeStream = null;<br>    }<br>}<br><br>let dest = new Transform({<br>    transform: (chunk, enc, next) =&gt; {<br>        if (!audio_buffer) {<br>            audio_buffer = chunk;<br>        } else {<br>            // append data to audio buffer<br>            audio_buffer = Buffer.concat([audio_buffer, chunk]);<br>        }<br>        console.log(&#39;chunk length: &#39;, chunk.length);<br>        next(null, chunk);<br>    }<br>}).on(&#39;data&#39;, (data) =&gt; {});<br><br>function writeDataToRecognizeStream() {<br>    // select a size of data to be removed from buffer depending on current size of audio_buffer<br>    let write_size = audio_buffer ?<br>        (audio_buffer.length &gt; 1280000 ? out_write_size.high :<br>            (audio_buffer.length &gt; 640000 ? out_write_size.medium :<br>                (audio_buffer.length &gt; 320000) ? out_write_size.low : out_write_size.very_low)) :<br>        out_write_size.very_low;<br><br>    if (audio_buffer &amp;&amp; (audio_buffer.length &gt;= write_size)) {<br>        if (recognizeStream) {<br>            // remove the chunks of selected size and write to recognizeStream<br>            let data_to_write = audio_buffer.slice(0, write_size);<br>            audio_buffer = audio_buffer.slice(write_size);<br>            recognizeStream.write(data_to_write);<br>        } else {<br>            console.log(&quot;no recognise stream&quot;);<br>        }<br>    } else {<br>        // no data coming from stream, write 0&#39;s into stream<br>        console.log(&quot;Nothing to write, buffer empty, writing dummy chunk&quot;);<br>        recognizeStream.write(empty_buffer);<br>    }<br>}<br><br>// ffmpeg processing<br>let command = ffmpeg(livestream_endpoint)<br>    .on(&#39;start&#39;, () =&gt; {<br>        startStream();<br>        console.log(&quot;ffmpeg : processing Started&quot;);<br>    })<br>    .on(&#39;progress&#39;, (progress) =&gt; {<br>        if (isFirstProgress) {<br>            // write data into recognizeStream after every 1 second<br>            setInterval(writeDataToRecognizeStream, 1000);<br>        }<br>        isFirstProgress = false;<br>        console.log(&#39;ffmpeg : Processing: &#39; + progress.targetSize + &#39;   KB converted&#39;);<br>    })<br>    .on(&#39;end&#39;, () =&gt; {<br>        console.log(&#39;ffmpeg : Processing finished !&#39;);<br>    })<br>    .on(&#39;error&#39;, (err) =&gt; {<br>        console.log(&#39;ffmpeg : ffmpeg error :&#39; + err.message);<br>    })<br>    .format(&#39;flac&#39;)<br>    .audioCodec(&#39;flac&#39;)<br>    .output(dest)<br>command.run();</pre><h4><strong>Summary:</strong></h4><ul><li>You won’t face the resource exhausted error since you’re controlling the audio data and then writing it into google cloud speech to text stream.</li><li>The chunks are getting written into the stream at a continuous interval and when there’s absolutely no audio data coming from m3u8 stream, we’re writing 0’s into recognizeStream, hence Error 11 (Long time elapsed without audio) is solved.</li><li>The key to solve Error 11 (Exceeded maximum allowed stream duration of 305 seconds) is to call recognizeStream.destroy();in your restartStream() method. This ensures that the recognizeStream which is currently open, is closed properly, then sets it to null. If you don’t destroy it, the stream remains open for maximum allowed duration of 305 seconds, causing the error.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a471c47fdec" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>