<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Shreyash</title>
    <description>The latest articles on DEV Community by Shreyash (@shreyashmohadikar).</description>
    <link>https://dev.to/shreyashmohadikar</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F600381%2Fa652256a-50bc-4efe-852a-59e158c48734.png</url>
      <title>DEV Community: Shreyash</title>
      <link>https://dev.to/shreyashmohadikar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shreyashmohadikar"/>
    <language>en</language>
    <item>
      <title>Sashido and ml project</title>
      <dc:creator>Shreyash</dc:creator>
      <pubDate>Sun, 21 Mar 2021 06:29:03 +0000</pubDate>
      <link>https://dev.to/shreyashmohadikar/sashido-and-ml-project-d2j</link>
      <guid>https://dev.to/shreyashmohadikar/sashido-and-ml-project-d2j</guid>
      <description>&lt;p&gt;'''#code starts&lt;br&gt;
import speech_recognition as sr  # recognise speech&lt;br&gt;
import playsound  # to play an audio file&lt;br&gt;
from gtts import gTTS  # google text to speech&lt;br&gt;
import random&lt;br&gt;
from time import ctime  # get time details&lt;br&gt;
import webbrowser  # open browser&lt;br&gt;
import ssl&lt;br&gt;
import certifi&lt;br&gt;
import time&lt;br&gt;
import os  # to remove created audio files&lt;br&gt;
from PIL import Image&lt;br&gt;
import subprocess&lt;br&gt;
import pyautogui  # screenshot&lt;br&gt;
import pyttsx3&lt;br&gt;
import bs4 as bs&lt;br&gt;
import urllib.request&lt;br&gt;
import requests&lt;/p&gt;

&lt;p&gt;class person:&lt;br&gt;
    name = ''&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def setName(self, name):
    self.name = name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;class asis:&lt;br&gt;
    name = ''&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def setName(self, name):
    self.name = name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;def there_exists(terms):&lt;br&gt;
    for term in terms:&lt;br&gt;
        if term in voice_data:&lt;br&gt;
            return True&lt;/p&gt;

&lt;p&gt;def engine_speak(text):&lt;br&gt;
    text = str(text)&lt;br&gt;
    engine.say(text)&lt;br&gt;
    engine.runAndWait()&lt;/p&gt;

&lt;p&gt;r = sr.Recognizer()  # initialise a recogniser&lt;/p&gt;

&lt;h1&gt;
  
  
  listen for audio and convert it to text:
&lt;/h1&gt;

&lt;p&gt;def record_audio(ask=""):&lt;br&gt;
    with sr.Microphone() as source:  # microphone as source&lt;br&gt;
        if ask:&lt;br&gt;
            engine_speak(ask)&lt;br&gt;
        audio = r.listen(source, 5, 5)  # listen for the audio via source&lt;br&gt;
        print("Done Listening")&lt;br&gt;
        voice_data = ''&lt;br&gt;
        try:&lt;br&gt;
            voice_data = r.recognize_google(audio)  # convert audio to text&lt;br&gt;
        except sr.UnknownValueError:  # error: recognizer does not understand&lt;br&gt;
            engine_speak('I did not get that')&lt;br&gt;
        except sr.RequestError:&lt;br&gt;
            engine_speak('Sorry, the service is down')  # error: recognizer is not connected&lt;br&gt;
        print("&amp;gt;&amp;gt;", voice_data.lower())  # print what user said&lt;br&gt;
        return voice_data.lower()&lt;/p&gt;

&lt;h1&gt;
  
  
  get string and make a audio file to be played
&lt;/h1&gt;

&lt;p&gt;def engine_speak(audio_string):&lt;br&gt;
    audio_string = str(audio_string)&lt;br&gt;
    tts = gTTS(text=audio_string, lang='en')  # text to speech(voice)&lt;br&gt;
    r = random.randint(1, 20000000)&lt;br&gt;
    audio_file = 'audio' + str(r) + '.mp3'&lt;br&gt;
    tts.save(audio_file)  # save as mp3&lt;br&gt;
    playsound.playsound(audio_file)  # play the audio file&lt;br&gt;
    print(asis_obj.name + ":", audio_string)  # print what app said&lt;br&gt;
    os.remove(audio_file)  # remove audio file&lt;/p&gt;

&lt;p&gt;def respond(voice_data):&lt;br&gt;
    # 1: greeting&lt;br&gt;
    if there_exists(['hey', 'hi', 'hello']):&lt;br&gt;
        greetings = ["hey, how can I help you" + person_obj.name, "hey, what's up?" + person_obj.name,&lt;br&gt;
                     "I'm listening" + person_obj.name, "how can I help you?" + person_obj.name,&lt;br&gt;
                     "hello" + person_obj.name]&lt;br&gt;
        greet = greetings[random.randint(0, len(greetings) - 1)]&lt;br&gt;
        engine_speak(greet)&lt;br&gt;
    # 2: name&lt;br&gt;
    if there_exists(["what is your name", "what's your name", "tell me your name"]):&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    if person_obj.name:
        engine_speak(f"My name is {asis_obj.name}, {person_obj.name}")  # gets users name from voice input
    else:
        engine_speak(f"My name is {asis_obj.name}. what's your name?")  # incase you haven't provided your name.

if there_exists(["my name is"]):
    person_name = voice_data.split("is")[-1].strip()
    engine_speak("okay, i will remember that " + person_name)
    person_obj.setName(person_name)  # remember name in person object

if there_exists(["what is my name"]):
    engine_speak("Your name must be " + person_obj.name)

if there_exists(["your name should be"]):
    asis_name = voice_data.split("be")[-1].strip()
    engine_speak("okay, i will remember that my name is " + asis_name)
    asis_obj.setName(asis_name)  # remember name in asis object

# 3: greeting
if there_exists(["how are you", "how are you doing"]):
    engine_speak("I'm very well, thanks for asking " + person_obj.name)

# 4: time
if there_exists(["what's the time", "tell me the time", "what time is it", "what is the time"]):
    time = ctime().split(" ")[3].split(":")[0:2]
    if time[0] == "00":
        hours = '12'
    else:
        hours = time[0]
    minutes = time[1]
    time = hours + " hours and " + minutes + "minutes"
    engine_speak(time)

# 5: search google
if there_exists(["search for"]) and 'youtube' not in voice_data:
    search_term = voice_data.split("for")[-1]
    url = "https://google.com/search?q=" + search_term
    webbrowser.get().open(url)
    engine_speak("Here is what I found for" + search_term + "on google")

if there_exists(["search"]) and 'youtube' not in voice_data:
    search_term = voice_data.replace("search", "")
    url = "https://google.com/search?q=" + search_term
    webbrowser.get().open(url)
    engine_speak("Here is what I found for" + search_term + "on google")

# 6: search youtube
if there_exists(["youtube"]):
    search_term = voice_data.split("for")[-1]
    search_term = search_term.replace("on youtube", "").replace("search", "")
    url = "https://www.youtube.com/results?search_query=" + search_term
    webbrowser.get().open(url)
    engine_speak("Here is what I found for " + search_term + "on youtube")

# 7: get stock price
if there_exists(["price of"]):
    search_term = voice_data.split("for")[-1]
    url = "https://google.com/search?q=" + search_term
    webbrowser.get().open(url)
    engine_speak("Here is what I found for " + search_term + " on google")

# 8 time table
if there_exists(["show my time table"]):
    im = Image.open(r"D:\WhatsApp Image 2019-12-26 at 10.51.10 AM.jpeg")
    im.show()

# 9 weather
if there_exists(["weather"]):
    search_term = voice_data.split("for")[-1]
    url = "https://www.google.com/search?sxsrf=ACYBGNSQwMLDByBwdVFIUCbQqya-ET7AAA%3A1578847393212&amp;amp;ei=oUwbXtbXDN-C4-EP-5u82AE&amp;amp;q=weather&amp;amp;oq=weather&amp;amp;gs_l=psy-ab.3..35i39i285i70i256j0i67l4j0i131i67j0i131j0i67l2j0.1630.4591..5475...1.2..2.322.1659.9j5j0j1......0....1..gws-wiz.....10..0i71j35i39j35i362i39._5eSPD47bv8&amp;amp;ved=0ahUKEwiWrJvwwP7mAhVfwTgGHfsNDxsQ4dUDCAs&amp;amp;uact=5"
    webbrowser.get().open(url)
    engine_speak("Here is what I found for on google")

# 10 stone paper scisorrs
if there_exists(["game"]):
    voice_data = record_audio("choose among rock paper or scissor")
    moves = ["rock", "paper", "scissor"]

    cmove = random.choice(moves)
    pmove = voice_data

    engine_speak("The computer chose " + cmove)
    engine_speak("You chose " + pmove)
    # engine_speak("hi")
    if pmove == cmove:
        engine_speak("the match is draw")
    elif pmove == "rock" and cmove == "scissor":
        engine_speak("Player wins")
    elif pmove == "rock" and cmove == "paper":
        engine_speak("Computer wins")
    elif pmove == "paper" and cmove == "rock":
        engine_speak("Player wins")
    elif pmove == "paper" and cmove == "scissor":
        engine_speak("Computer wins")
    elif pmove == "scissor" and cmove == "paper":
        engine_speak("Player wins")
    elif pmove == "scissor" and cmove == "rock":
        engine_speak("Computer wins")

# 11 toss a coin
if there_exists(["toss", "flip", "coin"]):
    moves = ["head", "tails"]
    cmove = random.choice(moves)
    engine_speak("The computer chose " + cmove)

# 12 calc
if there_exists(["plus", "minus", "multiply", "divide", "power", "+", "-", "*", "/"]):
    opr = voice_data.split()[1]

    if opr == '+':
        engine_speak(int(voice_data.split()[0]) + int(voice_data.split()[2]))
    elif opr == '-':
        engine_speak(int(voice_data.split()[0]) - int(voice_data.split()[2]))
    elif opr == 'multiply' or 'x':
        engine_speak(int(voice_data.split()[0]) * int(voice_data.split()[2]))
    elif opr == 'divide':
        engine_speak(int(voice_data.split()[0]) / int(voice_data.split()[2]))
    elif opr == 'power':
        engine_speak(int(voice_data.split()[0]) ** int(voice_data.split()[2]))
    else:
        engine_speak("Wrong Operator")

# 13 screenshot
if there_exists(["capture", "my screen", "screenshot"]):
    myScreenshot = pyautogui.screenshot()
    myScreenshot.save('D:\\screenshot\\screenshot.png')

# 14 to search wikipedia for definition
if there_exists(["definition of"]):
    definition = record_audio("what do you need the definition of")
    url = urllib.request.urlopen('https://en.wikipedia.org/wiki/' + definition)
    soup = bs.BeautifulSoup(url, 'lxml')
    definitions = []
    for paragraph in soup.find_all('p'):
        definitions.append(str(paragraph.text))
    if definitions:
        if definitions[0]:
            engine_speak('im sorry i could not find that definition, please try a web search')
        elif definitions[1]:
            engine_speak('here is what i found ' + definitions[1])
        else:
            engine_speak('Here is what i found ' + definitions[2])
    else:
        engine_speak("im sorry i could not find the definition for " + definition)

if there_exists(["exit", "quit", "goodbye"]):
    engine_speak("bye")
    exit()

# Current city or region
if there_exists(["where am i"]):
    Ip_info = requests.get('https://api.ipdata.co?api-key=test').json()
    loc = Ip_info['region']
    engine_speak(f"You must be somewhere in {loc}")

    # Current location as per Google maps
if there_exists(["what is my exact location"]):
    url = "https://www.google.com/maps/search/Where+am+I+?/"
    webbrowser.get().open(url)
    engine_speak("You must be somewhere near here, as per Google maps")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;time.sleep(1)&lt;/p&gt;

&lt;p&gt;person_obj = person()&lt;br&gt;
asis_obj = asis()&lt;br&gt;
asis_obj.name = 'Lucy'&lt;br&gt;
person_obj.name = ""&lt;br&gt;
engine = pyttsx3.init()&lt;/p&gt;

&lt;p&gt;while (1):&lt;br&gt;
    voice_data = record_audio("Recording")  # get the voice input&lt;br&gt;
    print("Done")&lt;br&gt;
    print("Q:", voice_data)&lt;br&gt;
    respond(voice_data)  # respond'''&lt;/p&gt;

</description>
      <category>geekweeklocal</category>
      <category>geeksforgeeksvitb</category>
      <category>sashido</category>
    </item>
    <item>
      <title>Geekweeklocal - One of my best experience</title>
      <dc:creator>Shreyash</dc:creator>
      <pubDate>Sat, 20 Mar 2021 14:33:21 +0000</pubDate>
      <link>https://dev.to/shreyashmohadikar/geekweeklocal-one-of-my-best-experience-4j11</link>
      <guid>https://dev.to/shreyashmohadikar/geekweeklocal-one-of-my-best-experience-4j11</guid>
      <description>&lt;p&gt;Geek Week Local&lt;/p&gt;

&lt;p&gt;A great initiative by GFG Vit Bhopal Chapter. We were asked to be a part of the guild and then solve challenges.&lt;/p&gt;

&lt;p&gt;The first thing of joining a guild was fun when we searched and interacted with people to join a team. It was really fun to do that and pitch others and persuade them to join the guild.&lt;/p&gt;

&lt;p&gt;Then the tasks began and the first day was light. But then it was escalated. Day 2 brought some tougher and interesting challenges&lt;br&gt;
Throughout everyday we learnt something new and improves upon ourselves.&lt;/p&gt;

&lt;p&gt;I learnt a lot. Learnt to create Portfolio, Github , Bootsrap, firebase and what not.&lt;/p&gt;

&lt;p&gt;So its a lots of a experience till now and expecting more such events by GFG.&lt;/p&gt;

</description>
      <category>geekweeklocal</category>
    </item>
  </channel>
</rss>
