-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathspeakMerlin.py
More file actions
32 lines (26 loc) · 996 Bytes
/
Copy pathspeakMerlin.py
File metadata and controls
32 lines (26 loc) · 996 Bytes
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
import os
import platform
import subprocess
def speakMerlin(text: str):
"""
Generate and play TTS audio that mimics an old man's voice using espeak.
:param text: The text to convert to speech.
"""
try:
# Customize espeak parameters for an old man's voice
pitch = 50 # Lower pitch for a deeper voice
speed = 100 # Slow down the speech
voice = "en+m7" # Use a male voice (f4 is a deeper male voice)
# Construct the espeak command
command = f'espeak -p {pitch} -s {speed} -v {voice} "{text}"'
# Execute the command based on the OS
if platform.system() == "Windows":
subprocess.Popen(command, shell=True)
else: # macOS and Linux
subprocess.Popen(command, shell=True)
except Exception as e:
print(f"An error occurred: {e}")
# Example usage
if __name__ == "__main__":
speakMerlin("Hello! I am the great merlin")
print("Trying to print wiuthhothu blocking")