abstractvoice 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,33 @@
1
+ """
2
+ AbstractVoice: A modular Python library for voice interactions with AI systems.
3
+
4
+ This package provides text-to-speech (TTS) and speech-to-text (STT)
5
+ capabilities with interrupt handling for AI interactions.
6
+ """
7
+
8
+ import warnings
9
+
10
+ # Suppress the PyTorch FutureWarning about torch.load
11
+ warnings.filterwarnings(
12
+ "ignore",
13
+ message="You are using `torch.load` with `weights_only=False`",
14
+ category=FutureWarning
15
+ )
16
+
17
+ # Suppress pkg_resources deprecation warning from jieba
18
+ warnings.filterwarnings(
19
+ "ignore",
20
+ message=".*pkg_resources.*",
21
+ category=UserWarning
22
+ )
23
+ warnings.filterwarnings(
24
+ "ignore",
25
+ message=".*pkg_resources.*",
26
+ category=DeprecationWarning
27
+ )
28
+
29
+ # Import the main class for public API
30
+ from .voice_manager import VoiceManager
31
+
32
+ __version__ = "0.2.0"
33
+ __all__ = ['VoiceManager']
@@ -0,0 +1,119 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ AbstractVoice - A modular Python library for voice interactions with AI systems.
4
+
5
+ This module allows running the examples directly.
6
+ """
7
+
8
+ import sys
9
+ import argparse
10
+
11
+
12
+ def print_examples():
13
+ """Print available examples."""
14
+ print("Available examples:")
15
+ print(" cli - Command-line REPL example")
16
+ print(" web - Web API example")
17
+ print(" simple - Simple usage example")
18
+ print("\nUsage: python -m abstractvoice <example> [args...]")
19
+
20
+
21
+ def simple_example():
22
+ """Run a simple example demonstrating basic usage."""
23
+ from abstractvoice import VoiceManager
24
+ import time
25
+
26
+ print("Simple AbstractVoice Example")
27
+ print("============================")
28
+ print("This example demonstrates basic TTS and STT functionality.")
29
+ print()
30
+
31
+ # Initialize voice manager
32
+ manager = VoiceManager(debug_mode=True)
33
+
34
+ try:
35
+ # TTS example
36
+ print("Speaking a welcome message...")
37
+ manager.speak("Hello! I'm a voice assistant powered by AbstractVoice. "
38
+ "I can speak and listen to you.")
39
+
40
+ # Wait for speech to complete
41
+ while manager.is_speaking():
42
+ time.sleep(0.1)
43
+
44
+ print("\nNow I'll listen for 10 seconds. Say something!")
45
+
46
+ # Store transcribed text
47
+ transcribed_text = None
48
+
49
+ # Callback for speech recognition
50
+ def on_transcription(text):
51
+ nonlocal transcribed_text
52
+ print(f"\nTranscribed: {text}")
53
+ transcribed_text = text
54
+
55
+ # If user says stop, stop listening
56
+ if text.lower() == "stop":
57
+ return
58
+
59
+ # Otherwise respond
60
+ print("Responding...")
61
+ manager.speak(f"You said: {text}")
62
+
63
+ # Start listening
64
+ manager.listen(on_transcription)
65
+
66
+ # Listen for 10 seconds or until "stop" is said
67
+ start_time = time.time()
68
+ while time.time() - start_time < 10 and manager.is_listening():
69
+ time.sleep(0.1)
70
+
71
+ # Stop listening if still active
72
+ if manager.is_listening():
73
+ manager.stop_listening()
74
+ print("\nDone listening.")
75
+
76
+ # If something was transcribed, repeat it back
77
+ if transcribed_text and transcribed_text.lower() != "stop":
78
+ print("\nSaying goodbye...")
79
+ manager.speak("Thanks for trying AbstractVoice! Goodbye!")
80
+ while manager.is_speaking():
81
+ time.sleep(0.1)
82
+
83
+ print("\nExample complete!")
84
+
85
+ finally:
86
+ # Clean up
87
+ manager.cleanup()
88
+
89
+
90
+ def main():
91
+ """Main entry point."""
92
+ parser = argparse.ArgumentParser(description="AbstractVoice examples")
93
+ parser.add_argument("example", nargs="?", help="Example to run (cli, web, simple)")
94
+
95
+ # Parse just the first argument
96
+ args, remaining = parser.parse_known_args()
97
+
98
+ if not args.example:
99
+ print_examples()
100
+ return
101
+
102
+ # Set remaining args as sys.argv for the examples
103
+ sys.argv = [sys.argv[0]] + remaining
104
+
105
+ if args.example == "cli":
106
+ from abstractvoice.examples.cli_repl import main
107
+ main()
108
+ elif args.example == "web":
109
+ from abstractvoice.examples.web_api import main
110
+ main()
111
+ elif args.example == "simple":
112
+ simple_example()
113
+ else:
114
+ print(f"Unknown example: {args.example}")
115
+ print_examples()
116
+
117
+
118
+ if __name__ == "__main__":
119
+ main()
@@ -0,0 +1 @@
1
+ """Example applications using the AbstractVoice package."""