-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHLEngine_AudioProcessing.py
More file actions
82 lines (57 loc) · 2.05 KB
/
HLEngine_AudioProcessing.py
File metadata and controls
82 lines (57 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#author:Akhil P Jacob
#HLDynamic-Integrations
from gtts import gTTS
import pygame
import pyttsx3
from playsound import playsound
def soundPlayer(location):
try:
playsound(location)
except:
return ("HLEngine:an issue in playing sound detected")
def saveAudio(param,location):
try:
mytext = param
language = 'en'
myobj = gTTS(text=mytext, lang=language, slow=False)
myobj.save(location)
except:
return ("HLEngine:saveAudio issue detected")
def playAudio(location):
try:
pygame.init()
pygame.mixer.init()
pygame.mixer.music.load(location)
pygame.mixer.music.play()
pygame.event.wait()
except:
return ("HLEngine:playAudio issue detected")
def readText(param):
try:
engine = pyttsx3.init()
engine.getProperty('rate')
engine.setProperty('rate', 125)
engine.say(param)
engine.runAndWait()
except:
return ("HLEngine cannot load the required necessay files")
def readTextSpec(param):
try:
engine = pyttsx3.init() # object creation
""" RATE"""
rate = engine.getProperty('rate') # getting details of current speaking rate
print(rate) # printing current voice rate
engine.setProperty('rate', 125) # setting up new voice rate
"""VOLUME"""
volume = engine.getProperty('volume') # getting to know current volume level (min=0 and max=1)
print(volume) # printing current volume level
engine.setProperty('volume', 1.0) # setting up volume level between 0 and 1
"""VOICE"""
voices = engine.getProperty('voices') # getting details of current voice
# engine.setProperty('voice', voices[0].id) #changing index, changes voices. o for male
engine.setProperty('voice', voices[1].id) # changing index, changes voices. 1 for female
engine.say(param + str(rate))
engine.runAndWait()
engine.stop()
except:
return("HLEngine: An error occured in readAudioSpec")