-
Notifications
You must be signed in to change notification settings - Fork 0
/
live-vc.py
80 lines (68 loc) · 2.93 KB
/
live-vc.py
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
79
80
import cmd
import os
from src.audio_handler import AudioHandler
import colorama
from dotenv import load_dotenv
load_dotenv()
colorama.init()
banner = """
██╗ ██╗██╗ ██╗███████╗ ██╗ ██╗ ██████╗
██║ ██║██║ ██║██╔════╝ ██║ ██║██╔════╝
██║ ██║██║ ██║█████╗█████╗██║ ██║██║
██║ ██║╚██╗ ██╔╝██╔══╝╚════╝╚██╗ ██╔╝██║
███████╗██║ ╚████╔╝ ███████╗ ╚████╔╝ ╚██████╗
╚══════╝╚═╝ ╚═══╝ ╚══════╝ ╚═══╝ ╚═════╝
"""
description = """Description: A live voice-changer utilizing elevenlabs voice-cloning API.
Author: https://github.com/cavoq
Version: 1.0.0
"""
class ElevenlabsLiveVCCmd(cmd.Cmd):
intro = f"""{colorama.Fore.GREEN}{banner}\n{
description}{colorama.Style.RESET_ALL}\n"""
prompt = f"{colorama.Fore.LIGHTBLUE_EX}(live-vc){colorama.Style.RESET_ALL}"
def __init__(self):
super().__init__()
self.audio_handler = AudioHandler.from_env()
def do_clear(self, arg=None):
"""Clear the screen."""
if os.name == 'nt':
os.system('cls')
else:
os.system('clear')
print(self.intro)
def do_quit(self, arg=None):
"""Quit the program."""
print(f"Exiting...")
return True
def do_set_mode(self, arg):
"""Set the mode to automatic (1) or manual (0)."""
try:
mode = int(arg)
if mode not in self.audio_handler.recorder.settings.valid_modes():
print(
f"{colorama.Fore.YELLOW}Invalid mode. Please enter 0 for manual or 1 for automatic.{
colorama.Style.RESET_ALL}"
)
return
self.audio_handler.recorder.settings.mode = mode
mode_str = "automatic" if self.audio_handler.recorder.settings.mode == 1 else "manual"
print(
f"{colorama.Fore.GREEN}Mode set to {mode_str}.{
colorama.Style.RESET_ALL}"
)
except ValueError:
print(
f"{colorama.Fore.YELLOW}Invalid input. Please enter 0 for manual or 1 for automatic.{
colorama.Style.RESET_ALL}"
)
def do_get_mode(self, arg):
"""Get the current mode (1 = automatic, 0 = manual)."""
mode_str = "automatic" if self.audio_handler.recorder.settings.mode == 1 else "manual"
print(f"Current mode is {mode_str}.")
if __name__ == "__main__":
try:
ElevenlabsLiveVCCmd().cmdloop()
except KeyboardInterrupt:
print("\nExiting gracefully...")
exit(0)