<?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 Sanjay Kumar on Medium]]></title>
        <description><![CDATA[Stories by Sanjay Kumar on Medium]]></description>
        <link>https://medium.com/@sanjay.kumar_16187?source=rss-94c524d1e8d1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Sanjay Kumar on Medium</title>
            <link>https://medium.com/@sanjay.kumar_16187?source=rss-94c524d1e8d1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 15:46:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sanjay.kumar_16187/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[Jetpack viewpager2 help]]></title>
            <link>https://medium.com/@sanjay.kumar_16187/jetpack-viewpager2-help-6af586dc864?source=rss-94c524d1e8d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/6af586dc864</guid>
            <dc:creator><![CDATA[Sanjay Kumar]]></dc:creator>
            <pubDate>Mon, 08 Nov 2021 10:11:23 GMT</pubDate>
            <atom:updated>2021-11-08T10:11:23.820Z</atom:updated>
            <content:encoded><![CDATA[<p>Its very easy to do horizontal scrolls with tablayout</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6af586dc864" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cartoon image in python]]></title>
            <link>https://medium.com/@sanjay.kumar_16187/cartoon-image-in-python-4656742a123f?source=rss-94c524d1e8d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/4656742a123f</guid>
            <dc:creator><![CDATA[Sanjay Kumar]]></dc:creator>
            <pubDate>Mon, 14 Sep 2020 09:33:21 GMT</pubDate>
            <atom:updated>2020-09-15T10:33:54.899Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*uUSVVWxm7VK5603P3smJRw.png" /><figcaption>Orginal</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*FG8kX1WFY9nP3NOV4xGBgg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*H0JkZ2nQ69GgGJPn6HL5GA.png" /></figure><p>import cv2<br>import numpy as np</p><p>img = cv2.imread(‘download.jpg’)<br>edges1 = cv2.bitwise_not(cv2.Canny(img, 100, 200)) # for thin edges and inverting the mask obatined<br>gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)<br>gray = cv2.medianBlur(gray, 5) # applying median blur with kernel size of 5<br>edges2 = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 7, 7) # thick edges<br>dst = cv2.edgePreservingFilter(img, flags=2, sigma_s=64, sigma_r=0.25) # you can also use bilateral filter but that is slow<br># flag = 1 for RECURS_FILTER (Recursive Filtering) and 2 for NORMCONV_FILTER (Normalized Convolution). NORMCONV_FILTER produces sharpening of the edges but is slower.<br># sigma_s controls the size of the neighborhood. Range 1–200<br># sigma_r controls the how dissimilar colors within the neighborhood will be averaged. A larger sigma_r results in large regions of constant color. Range 0–1<br>cartoon1 = cv2.bitwise_and(dst, dst, mask=edges1) # adding thin edges to smoothened image<br>cartoon2 = cv2.bitwise_and(dst, dst, mask=edges2) # adding thick edges to smoothened image<br>print(cartoon1)<br>cv2.imshow(“Image”, img)<br>cv2.imshow(“Cartoon1”, cartoon1)<br>cv2.imshow(“Cartoon2”, cartoon2)<br>cv2.waitKey(0)<br>cv2.destroyAllWindows()</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4656742a123f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Speech Recognition using Wit.ai]]></title>
            <link>https://medium.com/@sanjay.kumar_16187/speech-recognition-using-wit-ai-a512c1e0e6b5?source=rss-94c524d1e8d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/a512c1e0e6b5</guid>
            <category><![CDATA[facebook]]></category>
            <category><![CDATA[witai]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Sanjay Kumar]]></dc:creator>
            <pubDate>Sun, 26 Jul 2020 12:58:04 GMT</pubDate>
            <atom:updated>2020-07-26T12:58:04.791Z</atom:updated>
            <content:encoded><![CDATA[<p>it is free| open-source | easy to customized|Owned by Facebook</p><p>Step 1.</p><p>Create an API Key</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P-GxD6Wge-jGmf5dnrchAA.png" /></figure><p>Step 2.</p><p>Python script to record audio</p><p><strong>Windows:</strong> Just install PyAudio module using a simple pip command.</p><p><strong>pip install pyaudio</strong></p><blockquote>If you get this “Error: Microsoft visual C++ 14.0 required.” then go to this link <a href="https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio">https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio</a></blockquote><blockquote>PyAudio‑0.2.11‑cp38‑cp38‑win32.whl — for 32</blockquote><blockquote>PyAudio‑0.2.11‑cp37‑cp37m‑win_amd64.whl -for 64</blockquote><p><strong>Recorder.py</strong></p><pre>Recorder.py</pre><pre>import pyaudio<br>import wave</pre><pre>def record_audio(RECORD_SECONDS, WAVE_OUTPUT_FILENAME):<br>    #--------- SETTING PARAMS FOR OUR AUDIO FILE ------------#<br>    FORMAT = pyaudio.paInt16    # format of wave<br>    CHANNELS = 2                # no. of audio channels<br>    RATE = 44100                # frame rate<br>    CHUNK = 1024                # frames per audio sample<br>    #--------------------------------------------------------#<br>     <br>    # creating PyAudio object<br>    audio = pyaudio.PyAudio()<br>     <br>    # open a new stream for microphone<br>    # It creates a PortAudio Stream Wrapper class object<br>    stream = audio.open(format=FORMAT,channels=CHANNELS,<br>                        rate=RATE, input=True,<br>                        frames_per_buffer=CHUNK)</pre><pre>#----------------- start of recording -------------------#<br>    print(&quot;Listening...&quot;)</pre><pre># list to save all audio frames<br>    frames = []</pre><pre>for i in range(int(RATE / CHUNK * RECORD_SECONDS)):<br>        # read audio stream from microphone<br>        data = stream.read(CHUNK)<br>        # append audio data to frames list<br>        frames.append(data)</pre><pre>#------------------ end of recording --------------------#   <br>    print(&quot;Finished recording.&quot;)<br>      <br>    stream.stop_stream()    # stop the stream object<br>    stream.close()          # close the stream object<br>    audio.terminate()       # terminate PortAudio</pre><pre>#------------------ saving audio ------------------------#</pre><pre># create wave file object<br>    waveFile = wave.open(WAVE_OUTPUT_FILENAME, &#39;wb&#39;)</pre><pre># settings for wave file object<br>    waveFile.setnchannels(CHANNELS)<br>    waveFile.setsampwidth(audio.get_sample_size(FORMAT))<br>    waveFile.setframerate(RATE)<br>    waveFile.writeframes(b&#39;&#39;.join(frames))</pre><pre># closing the wave file object<br>    waveFile.close()</pre><pre>def read_audio(WAVE_FILENAME):<br>    # function to read audio(wav) file<br>    with open(WAVE_FILENAME, &#39;rb&#39;) as f:<br>        audio = f.read()<br>    return audio</pre><p>Speech_to_text.py</p><pre>import requests<br>import json<br>from Recorder import record_audio, read_audio</pre><pre># Wit speech API endpoint<br>API_ENDPOINT = &#39;<a href="https://api.wit.ai/speech&#39;">https://api.wit.ai/speech&#39;</a></pre><pre># Wit.ai api access token<br>wit_access_token = &#39;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&#39;</pre><pre>headers = {&#39;authorization&#39;: &#39;Bearer &#39; + wit_access_token}</pre><pre>def RecognizeSpeech(AUDIO_FILENAME, num_seconds = 15):<br>    <br>    # record audio of specified length in specified audio file<br>    record_audio(num_seconds, AUDIO_FILENAME)<br>    <br>    # reading audio<br>    audio = read_audio(AUDIO_FILENAME)<br>    <br>    # defining headers for HTTP request<br>    headers = {&#39;authorization&#39;: &#39;Bearer &#39; + wit_access_token,<br>               &#39;Content-Type&#39;: &#39;audio/wav&#39;}</pre><pre># making an HTTP post request<br>    resp = requests.post(API_ENDPOINT, headers = headers,<br>                         data = audio)<br>    <br>    # converting response content to JSON format<br>    data = json.loads(resp.content)<br> <br>    json_formatted_str = json.dumps(data, indent=2)<br> <br>    print(json_formatted_str)</pre><pre># get text from data<br>    text = data[&#39;text&#39;]<br>    <br>    # return the text<br>    return text</pre><pre>if __name__ == &quot;__main__&quot;:<br>    text =  RecognizeSpeech(&#39;myspeech.wav&#39;, 40)<br>    print(&quot;\nYou said: {}&quot;.format(text))<br> <br>    resp=requests.get(&#39;<a href="https://api.wit.ai/message?&amp;q=(%s)&#39;">https://api.wit.ai/message?&amp;q=(%s)&#39;</a> % text, headers = headers)<br>    data = json.loads(resp.content)<br>    <br>    print(data)</pre><pre>text =  RecognizeSpeech(&#39;myspeech.wav&#39;, 40) <br>Increase or the duration of wav file recording</pre><p>Run: python speech_to_text.py</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a512c1e0e6b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Image round in android]]></title>
            <link>https://medium.com/@sanjay.kumar_16187/image-round-in-android-79b9b18503fe?source=rss-94c524d1e8d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/79b9b18503fe</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[imageview]]></category>
            <dc:creator><![CDATA[Sanjay Kumar]]></dc:creator>
            <pubDate>Wed, 01 Jul 2020 08:34:18 GMT</pubDate>
            <atom:updated>2020-07-01T08:34:18.289Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ze5FyFWb9F5E7m_kR08cbg.png" /></figure><p>To set the image round on top-left,top-right without using any library. I used this :</p><pre><strong>public class </strong>RoundImageView <strong>extends </strong>AppCompatImageView {<br><br>    <strong>private float radius </strong>= 18.0f;<br>    <strong>private </strong>Path <strong>path</strong>;<br>    <strong>private </strong>RectF <strong>rect</strong>;<br><br>    <strong>public </strong>RoundImageView(Context context) {<br>        <strong>super</strong>(context);<br>        init();<br>    }<br><br>    <strong>public </strong>RoundImageView(Context context, AttributeSet attrs) {<br>        <strong>super</strong>(context, attrs);<br>        init();<br>    }<br><br>    <strong>public </strong>RoundImageView(Context context, AttributeSet attrs, <strong>int </strong>defStyle) {<br>        <strong>super</strong>(context, attrs, defStyle);<br>        init();<br>    }<br><br>    <strong>private void </strong>init() {<br>        <strong>path </strong>= <strong>new </strong>Path();<br><br>    }<br><br>    @Override<br>    <strong>protected void </strong>onDraw(Canvas canvas) {<br>        <strong>rect </strong>= <strong>new </strong>RectF(0, 0, <strong>this</strong>.getWidth(), <strong>this</strong>.getHeight());<br>        <strong>path</strong>=getPath(<strong>radius</strong>,<strong>true</strong>,<strong>true</strong>,<strong>false</strong>,<strong>false</strong>);<br>        canvas.clipPath(<strong>path</strong>);<br>        <strong>super</strong>.onDraw(canvas);<br>    }<br>    <strong>private </strong>Path getPath(<strong>float </strong>radius, <strong>boolean </strong>topLeft, <strong>boolean </strong>topRight,<br>                         <strong>boolean </strong>bottomRight, <strong>boolean </strong>bottomLeft) {<br><br>        <strong>final </strong>Path path = <strong>new </strong>Path();<br>        <strong>final float</strong>[] radii = <strong>new float</strong>[8];<br><br>        <strong>if </strong>(topLeft) {<br>            radii[0] = radius;<br>            radii[1] = radius;<br>        }<br><br>        <strong>if </strong>(topRight) {<br>            radii[2] = radius;<br>            radii[3] = radius;<br>        }<br><br>        <strong>if </strong>(bottomRight) {<br>            radii[4] = radius;<br>            radii[5] = radius;<br>        }<br><br>        <strong>if </strong>(bottomLeft) {<br>            radii[6] = radius;<br>            radii[7] = radius;<br>        }<br><br>        path.addRoundRect(<strong>new </strong>RectF(0, 0, getWidth(), getHeight()),<br>                radii, Path.Direction.<strong><em>CW</em></strong>);<br><br>        <strong>return </strong>path;<br>    }<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79b9b18503fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>