Skip to content

Commit 72d6f9e

Browse files
committed
voice assisted musicplayer system
1 parent 528b0fb commit 72d6f9e

11 files changed

+451
-0
lines changed

Diff for: scripts/Voice_Assited_Musicplayer/.gitignore

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
# C extensions
5+
*.so
6+
7+
# Distribution / packaging
8+
bin/
9+
build/
10+
develop-eggs/
11+
dist/
12+
eggs/
13+
lib/
14+
lib64/
15+
parts/
16+
sdist/
17+
var/
18+
*.egg-info/
19+
.installed.cfg
20+
*.egg
21+
22+
# Installer logs
23+
pip-log.txt
24+
pip-delete-this-directory.txt
25+
26+
# Unit test / coverage reports
27+
.tox/
28+
.coverage
29+
.cache
30+
nosetests.xml
31+
coverage.xml
32+
33+
# Translations
34+
*.mo
35+
36+
# Mr Developer
37+
.mr.developer.cfg
38+
.project
39+
.pydevproject
40+
41+
# Rope
42+
.ropeproject
43+
44+
# Django stuff:
45+
*.log
46+
*.pot
47+
48+
# Sphinx documentation
49+
docs/_build/

Diff for: scripts/Voice_Assited_Musicplayer/README.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
This project contains Ai powered voice activated music player system
2+
the system supports mp3,wav and mpeg audio files
3+
4+
To run the program execute the assistant.py file and say the desired song according to your mood
5+
6+
features of the music player:
7+
-backward button
8+
-forward button
9+
-pause/play button
10+
-progress bar
11+
-volume button
12+
-delete button
13+
-load file button
14+
15+
16+
Requirements:
17+
pyttsx3
18+
SpeechRecognition
19+
os
20+
datetime
21+
pickle
22+
tkinter
23+
pygame
24+
mutagen
25+
time
Binary file not shown.
Binary file not shown.

Diff for: scripts/Voice_Assited_Musicplayer/assistant.py

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import pyttsx3
2+
import speech_recognition as sr
3+
import datetime
4+
import os
5+
from player import run
6+
7+
engine = pyttsx3.init('sapi5')
8+
voices = engine.getProperty('voices')
9+
engine.setProperty('voice', voices[1].id)
10+
11+
playlist = []
12+
13+
14+
def speak(audio):
15+
engine.say(audio)
16+
engine.runAndWait()
17+
18+
19+
def bot_answer(answer):
20+
print("assistant:", answer)
21+
22+
23+
def greetings():
24+
global playlist
25+
hour = int(datetime.datetime.now().hour)
26+
if(hour >= 0 and hour < 12):
27+
speak("good morning")
28+
elif hour >= 12 and hour < 18:
29+
speak("good afternoon")
30+
else:
31+
speak("good evening")
32+
33+
speak("welcome to py-Musicplayer")
34+
bot_answer('say playlist name to play')
35+
playlist = os.listdir('Songs')
36+
bot_answer(playlist)
37+
38+
39+
def action_taker():
40+
r = sr.Recognizer()
41+
with sr.Microphone() as source:
42+
print("Listening...")
43+
speak("listening")
44+
r.adjust_for_ambient_noise(source, duration=5)
45+
audio = r.listen(source)
46+
47+
try:
48+
print("recognizing...")
49+
speak("recognizing")
50+
command = r.recognize_google(audio)
51+
print(f'User:{command}\n"')
52+
53+
except Exception as e:
54+
print(e)
55+
bot_answer("Say that again please....")
56+
57+
return "None"
58+
return command
59+
60+
61+
greetings()
62+
while True:
63+
command = action_taker().lower()
64+
song_playlist = list(map(str.lower, playlist))
65+
66+
if any(command in s for s in song_playlist):
67+
get_ind = song_playlist.index(command)
68+
playlist_name = playlist.index(command)
69+
playlist_name = playlist[get_ind]
70+
playlist_dir = os.path.abspath("./Songs/"+playlist_name)
71+
bot_answer('Playing: '+playlist_name +
72+
'playlist for you with Musicplayer')
73+
speak('playing:'+playlist_name+'playlist for you with music player')
74+
print(playlist_dir)
75+
run(playlist_dir)
76+
elif 'stop' in command:
77+
speak('good bye,have a good day')
78+
bot_answer('exit')
79+
engine.stop()
80+
break
81+
else:
82+
bot_answer('did not get the playlist...')
83+
speak('did not get the playlist')
84+
print(playlist)

Diff for: scripts/Voice_Assited_Musicplayer/images/image2.gif

32.9 KB
Loading

Diff for: scripts/Voice_Assited_Musicplayer/images/next.gif

1.51 KB
Loading

Diff for: scripts/Voice_Assited_Musicplayer/images/pause.gif

1.54 KB
Loading

Diff for: scripts/Voice_Assited_Musicplayer/images/play.gif

1.51 KB
Loading
1.54 KB
Loading

0 commit comments

Comments
 (0)