Skip to content

New branch artgoblin #411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions scripts/Voice_Assited_Musicplayer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# C extensions
*.so

# Distribution / packaging
bin/
build/
develop-eggs/
dist/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Translations
*.mo

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# Rope
.ropeproject

# Django stuff:
*.log
*.pot

# Sphinx documentation
docs/_build/
33 changes: 33 additions & 0 deletions scripts/Voice_Assited_Musicplayer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Voice_assisted_musicplayer
This project contains Ai powered voice activated music player system.
The system supports mp3,wav and mpeg audio files.
It can also play songs according to yor emotion(files need to be stored in voice_assisted_musicplayer/Songs/[-] **folder name according to your choice**)
It can also load music files form other directories.

To run the program execute the assistant.py file and say the desired song according to your mood
# preview
![image](https://user-images.githubusercontent.com/115635715/195788102-1906c8b2-edd7-456b-9a10-7130bfb19704.png)

![image](https://user-images.githubusercontent.com/115635715/195788334-144aab6a-bb67-42a1-a427-63ceef34a8fe.png)


## Features of the music player:
-backward button<br>
-forward button<br>
-pause/play button<br>
-progress bar<br>
-volume button<br>
-delete button<br>
-load file button<br>


## Requirements:<br>
pyttsx3<br>
SpeechRecognition<br>
os<br>
datetime<br>
pickle<br>
tkinter<br>
pygame<br>
mutagen<br>
time<br>
Binary file not shown.
Binary file not shown.
84 changes: 84 additions & 0 deletions scripts/Voice_Assited_Musicplayer/assistant.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import pyttsx3
import speech_recognition as sr
import datetime
import os
from player import run

engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)

playlist = []


def speak(audio):
engine.say(audio)
engine.runAndWait()


def bot_answer(answer):
print("assistant:", answer)


def greetings():
global playlist
hour = int(datetime.datetime.now().hour)
if(hour >= 0 and hour < 12):
speak("good morning")
elif hour >= 12 and hour < 18:
speak("good afternoon")
else:
speak("good evening")

speak("welcome to py-Musicplayer")
bot_answer('say playlist name to play')
playlist = os.listdir('Songs')
bot_answer(playlist)


def action_taker():
r = sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
speak("listening")
r.adjust_for_ambient_noise(source, duration=5)
audio = r.listen(source)

try:
print("recognizing...")
speak("recognizing")
command = r.recognize_google(audio)
print(f'User:{command}\n"')

except Exception as e:
print(e)
bot_answer("Say that again please....")

return "None"
return command


greetings()
while True:
command = action_taker().lower()
song_playlist = list(map(str.lower, playlist))

if any(command in s for s in song_playlist):
get_ind = song_playlist.index(command)
playlist_name = playlist.index(command)
playlist_name = playlist[get_ind]
playlist_dir = os.path.abspath("./Songs/"+playlist_name)
bot_answer('Playing: '+playlist_name +
'playlist for you with Musicplayer')
speak('playing:'+playlist_name+'playlist for you with music player')
print(playlist_dir)
run(playlist_dir)
elif 'stop' in command:
speak('good bye,have a good day')
bot_answer('exit')
engine.stop()
break
else:
bot_answer('did not get the playlist...')
speak('did not get the playlist')
print(playlist)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added scripts/Voice_Assited_Musicplayer/images/next.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added scripts/Voice_Assited_Musicplayer/images/play.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading