abstractvoice 0.2.1__tar.gz → 0.3.0__tar.gz

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.
Files changed (27) hide show
  1. {abstractvoice-0.2.1 → abstractvoice-0.3.0}/PKG-INFO +33 -7
  2. {abstractvoice-0.2.1 → abstractvoice-0.3.0}/README.md +32 -6
  3. {abstractvoice-0.2.1 → abstractvoice-0.3.0}/abstractvoice/examples/cli_repl.py +25 -1
  4. abstractvoice-0.3.0/abstractvoice/examples/voice_cli.py +249 -0
  5. {abstractvoice-0.2.1 → abstractvoice-0.3.0}/abstractvoice.egg-info/PKG-INFO +33 -7
  6. {abstractvoice-0.2.1 → abstractvoice-0.3.0}/abstractvoice.egg-info/entry_points.txt +0 -1
  7. {abstractvoice-0.2.1 → abstractvoice-0.3.0}/pyproject.toml +2 -3
  8. abstractvoice-0.2.1/abstractvoice/examples/voice_cli.py +0 -99
  9. {abstractvoice-0.2.1 → abstractvoice-0.3.0}/LICENSE +0 -0
  10. {abstractvoice-0.2.1 → abstractvoice-0.3.0}/abstractvoice/__init__.py +0 -0
  11. {abstractvoice-0.2.1 → abstractvoice-0.3.0}/abstractvoice/__main__.py +0 -0
  12. {abstractvoice-0.2.1 → abstractvoice-0.3.0}/abstractvoice/dependency_check.py +0 -0
  13. {abstractvoice-0.2.1 → abstractvoice-0.3.0}/abstractvoice/examples/__init__.py +0 -0
  14. {abstractvoice-0.2.1 → abstractvoice-0.3.0}/abstractvoice/examples/web_api.py +0 -0
  15. {abstractvoice-0.2.1 → abstractvoice-0.3.0}/abstractvoice/recognition.py +0 -0
  16. {abstractvoice-0.2.1 → abstractvoice-0.3.0}/abstractvoice/stt/__init__.py +0 -0
  17. {abstractvoice-0.2.1 → abstractvoice-0.3.0}/abstractvoice/stt/transcriber.py +0 -0
  18. {abstractvoice-0.2.1 → abstractvoice-0.3.0}/abstractvoice/tts/__init__.py +0 -0
  19. {abstractvoice-0.2.1 → abstractvoice-0.3.0}/abstractvoice/tts/tts_engine.py +0 -0
  20. {abstractvoice-0.2.1 → abstractvoice-0.3.0}/abstractvoice/vad/__init__.py +0 -0
  21. {abstractvoice-0.2.1 → abstractvoice-0.3.0}/abstractvoice/vad/voice_detector.py +0 -0
  22. {abstractvoice-0.2.1 → abstractvoice-0.3.0}/abstractvoice/voice_manager.py +0 -0
  23. {abstractvoice-0.2.1 → abstractvoice-0.3.0}/abstractvoice.egg-info/SOURCES.txt +0 -0
  24. {abstractvoice-0.2.1 → abstractvoice-0.3.0}/abstractvoice.egg-info/dependency_links.txt +0 -0
  25. {abstractvoice-0.2.1 → abstractvoice-0.3.0}/abstractvoice.egg-info/requires.txt +0 -0
  26. {abstractvoice-0.2.1 → abstractvoice-0.3.0}/abstractvoice.egg-info/top_level.txt +0 -0
  27. {abstractvoice-0.2.1 → abstractvoice-0.3.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: abstractvoice
3
- Version: 0.2.1
3
+ Version: 0.3.0
4
4
  Summary: A modular Python library for voice interactions with AI systems
5
5
  Author-email: Laurent-Philippe Albou <contact@abstractcore.ai>
6
6
  License-Expression: MIT
@@ -364,14 +364,40 @@ abstractvoice --debug --whisper base --model gemma3:latest --api http://localhos
364
364
  - **Note**: This creates a "TTS-only" mode where you type and the AI speaks back
365
365
  - `--system <prompt>` - Custom system prompt
366
366
 
367
+ ### 🎯 Complete CLI Interface (v0.3.0+)
368
+
369
+ AbstractVoice provides a unified command interface for all functionality:
370
+
371
+ ```bash
372
+ # Voice mode (default)
373
+ abstractvoice # Interactive voice mode with AI
374
+ abstractvoice --model cogito:3b # With custom Ollama model
375
+ abstractvoice --language fr # French voice mode
376
+
377
+ # Examples and utilities
378
+ abstractvoice cli # CLI REPL for text interaction
379
+ abstractvoice web # Web API server
380
+ abstractvoice simple # Simple TTS/STT demonstration
381
+ abstractvoice check-deps # Check dependency compatibility
382
+ abstractvoice help # Show available commands
383
+
384
+ # Get help
385
+ abstractvoice --help # Complete help with all options
386
+ ```
387
+
388
+ **All functionality through one command!** No more confusion between different entry points.
389
+
367
390
  ### Command-Line REPL
368
391
 
369
392
  ```bash
370
393
  # Run the CLI example (TTS ON, STT OFF)
371
- abstractvoice-cli cli
394
+ abstractvoice cli
372
395
 
373
396
  # With debug mode
374
- abstractvoice-cli cli --debug
397
+ abstractvoice cli --debug
398
+
399
+ # With specific language
400
+ abstractvoice cli --language fr
375
401
  ```
376
402
 
377
403
  #### REPL Commands
@@ -423,17 +449,17 @@ All commands must start with `/` except `stop`:
423
449
 
424
450
  ```bash
425
451
  # Run the web API example
426
- abstractvoice-cli web
452
+ abstractvoice web
427
453
 
428
454
  # With different host and port
429
- abstractvoice-cli web --host 0.0.0.0 --port 8000
455
+ abstractvoice web --host 0.0.0.0 --port 8000
430
456
  ```
431
457
 
432
458
  You can also run a simplified version that doesn't load the full models:
433
459
 
434
460
  ```bash
435
461
  # Run the web API with simulation mode
436
- abstractvoice-cli web --simulate
462
+ abstractvoice web --simulate
437
463
  ```
438
464
 
439
465
  #### Troubleshooting Web API
@@ -461,7 +487,7 @@ If you encounter issues with the web API:
461
487
 
462
488
  ```bash
463
489
  # Run the simple example
464
- abstractvoice-cli simple
490
+ abstractvoice simple
465
491
  ```
466
492
 
467
493
  ## Documentation
@@ -282,14 +282,40 @@ abstractvoice --debug --whisper base --model gemma3:latest --api http://localhos
282
282
  - **Note**: This creates a "TTS-only" mode where you type and the AI speaks back
283
283
  - `--system <prompt>` - Custom system prompt
284
284
 
285
+ ### 🎯 Complete CLI Interface (v0.3.0+)
286
+
287
+ AbstractVoice provides a unified command interface for all functionality:
288
+
289
+ ```bash
290
+ # Voice mode (default)
291
+ abstractvoice # Interactive voice mode with AI
292
+ abstractvoice --model cogito:3b # With custom Ollama model
293
+ abstractvoice --language fr # French voice mode
294
+
295
+ # Examples and utilities
296
+ abstractvoice cli # CLI REPL for text interaction
297
+ abstractvoice web # Web API server
298
+ abstractvoice simple # Simple TTS/STT demonstration
299
+ abstractvoice check-deps # Check dependency compatibility
300
+ abstractvoice help # Show available commands
301
+
302
+ # Get help
303
+ abstractvoice --help # Complete help with all options
304
+ ```
305
+
306
+ **All functionality through one command!** No more confusion between different entry points.
307
+
285
308
  ### Command-Line REPL
286
309
 
287
310
  ```bash
288
311
  # Run the CLI example (TTS ON, STT OFF)
289
- abstractvoice-cli cli
312
+ abstractvoice cli
290
313
 
291
314
  # With debug mode
292
- abstractvoice-cli cli --debug
315
+ abstractvoice cli --debug
316
+
317
+ # With specific language
318
+ abstractvoice cli --language fr
293
319
  ```
294
320
 
295
321
  #### REPL Commands
@@ -341,17 +367,17 @@ All commands must start with `/` except `stop`:
341
367
 
342
368
  ```bash
343
369
  # Run the web API example
344
- abstractvoice-cli web
370
+ abstractvoice web
345
371
 
346
372
  # With different host and port
347
- abstractvoice-cli web --host 0.0.0.0 --port 8000
373
+ abstractvoice web --host 0.0.0.0 --port 8000
348
374
  ```
349
375
 
350
376
  You can also run a simplified version that doesn't load the full models:
351
377
 
352
378
  ```bash
353
379
  # Run the web API with simulation mode
354
- abstractvoice-cli web --simulate
380
+ abstractvoice web --simulate
355
381
  ```
356
382
 
357
383
  #### Troubleshooting Web API
@@ -379,7 +405,7 @@ If you encounter issues with the web API:
379
405
 
380
406
  ```bash
381
407
  # Run the simple example
382
- abstractvoice-cli simple
408
+ abstractvoice simple
383
409
  ```
384
410
 
385
411
  ## Documentation
@@ -235,8 +235,32 @@ class VoiceREPL(cmd.Cmd):
235
235
  if self.voice_manager:
236
236
  self.voice_manager.speak(response_text)
237
237
 
238
+ except requests.exceptions.ConnectionError as e:
239
+ print(f"❌ Cannot connect to Ollama API at {self.api_url}")
240
+ print(f" Please check that Ollama is running and accessible")
241
+ print(f" Try: ollama serve")
242
+ if self.debug_mode:
243
+ print(f" Connection error: {e}")
244
+ except requests.exceptions.HTTPError as e:
245
+ if "404" in str(e):
246
+ print(f"❌ Model '{self.model}' not found on Ollama server")
247
+ print(f" Available models: Try 'ollama list' to see installed models")
248
+ print(f" To install a model: ollama pull {self.model}")
249
+ else:
250
+ print(f"❌ HTTP error from Ollama API: {e}")
251
+ if self.debug_mode:
252
+ print(f" Full error: {e}")
238
253
  except Exception as e:
239
- print(f"Error: {e}")
254
+ error_msg = str(e).lower()
255
+ if "model file not found" in error_msg or "no such file" in error_msg:
256
+ print(f"❌ Model '{self.model}' not found or not fully downloaded")
257
+ print(f" Try: ollama pull {self.model}")
258
+ print(f" Or use an existing model: ollama list")
259
+ elif "connection" in error_msg or "refused" in error_msg:
260
+ print(f"❌ Cannot connect to Ollama at {self.api_url}")
261
+ print(f" Make sure Ollama is running: ollama serve")
262
+ else:
263
+ print(f"❌ Error: {e}")
240
264
  if self.debug_mode:
241
265
  import traceback
242
266
  traceback.print_exc()
@@ -0,0 +1,249 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ AbstractVoice voice mode CLI launcher.
4
+
5
+ This module provides a direct entry point to start AbstractVoice in voice mode.
6
+ """
7
+
8
+ import argparse
9
+ import time
10
+ from abstractvoice.examples.cli_repl import VoiceREPL
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(" check-deps - Check dependency compatibility")
19
+ print("\nUsage: abstractvoice <example> [--language <lang>] [args...]")
20
+ print("\nSupported languages: en, fr, es, de, it, ru, multilingual")
21
+ print("\nExamples:")
22
+ print(" abstractvoice cli --language fr # French CLI")
23
+ print(" abstractvoice simple --language ru # Russian simple example")
24
+ print(" abstractvoice check-deps # Check dependencies")
25
+ print(" abstractvoice # Direct voice mode (default)")
26
+
27
+ def simple_example():
28
+ """Run a simple example demonstrating basic usage."""
29
+ from abstractvoice import VoiceManager
30
+ import time
31
+
32
+ print("Simple AbstractVoice Example")
33
+ print("============================")
34
+ print("This example demonstrates basic TTS and STT functionality.")
35
+ print("(Use --language argument to test different languages)")
36
+ print()
37
+
38
+ # Initialize voice manager (can be overridden with --language)
39
+ manager = VoiceManager(debug_mode=True)
40
+
41
+ try:
42
+ # TTS example
43
+ print("Speaking a welcome message...")
44
+ manager.speak("Hello! I'm a voice assistant powered by AbstractVoice. "
45
+ "I can speak and listen to you.")
46
+
47
+ # Wait for speech to complete
48
+ while manager.is_speaking():
49
+ time.sleep(0.1)
50
+
51
+ print("\nNow I'll listen for 10 seconds. Say something!")
52
+
53
+ # Store transcribed text
54
+ transcribed_text = None
55
+
56
+ # Callback for speech recognition
57
+ def on_transcription(text):
58
+ nonlocal transcribed_text
59
+ print(f"\nTranscribed: {text}")
60
+ transcribed_text = text
61
+
62
+ # If user says stop, stop listening
63
+ if text.lower() == "stop":
64
+ return
65
+
66
+ # Otherwise respond
67
+ print("Responding...")
68
+ manager.speak(f"You said: {text}")
69
+
70
+ # Start listening
71
+ manager.listen(on_transcription)
72
+
73
+ # Listen for 10 seconds or until "stop" is said
74
+ start_time = time.time()
75
+ while time.time() - start_time < 10 and manager.is_listening():
76
+ time.sleep(0.1)
77
+
78
+ # Stop listening if still active
79
+ if manager.is_listening():
80
+ manager.stop_listening()
81
+ print("\nDone listening.")
82
+
83
+ # If something was transcribed, repeat it back
84
+ if transcribed_text and transcribed_text.lower() != "stop":
85
+ print("\nSaying goodbye...")
86
+ manager.speak("Thanks for trying AbstractVoice! Goodbye!")
87
+ while manager.is_speaking():
88
+ time.sleep(0.1)
89
+
90
+ print("\nExample complete!")
91
+
92
+ finally:
93
+ # Clean up
94
+ manager.cleanup()
95
+
96
+ def parse_args():
97
+ """Parse command line arguments."""
98
+ parser = argparse.ArgumentParser(description="AbstractVoice - Voice interactions with AI")
99
+
100
+ # Examples and special commands
101
+ parser.add_argument("command", nargs="?", help="Command to run: cli, web, simple, check-deps (default: voice mode)")
102
+
103
+ # Voice mode arguments
104
+ parser.add_argument("--debug", action="store_true", help="Enable debug mode")
105
+ parser.add_argument("--api", default="http://localhost:11434/api/chat",
106
+ help="LLM API URL")
107
+ parser.add_argument("--model", default="granite3.3:2b",
108
+ help="LLM model name")
109
+ parser.add_argument("--whisper", default="tiny",
110
+ help="Whisper model to use (tiny, base, small, medium, large)")
111
+ parser.add_argument("--no-listening", action="store_true",
112
+ help="Disable speech-to-text (listening), TTS still works")
113
+ parser.add_argument("--system",
114
+ help="Custom system prompt")
115
+ parser.add_argument("--temperature", type=float, default=0.4,
116
+ help="Set temperature (0.0-2.0) for the LLM")
117
+ parser.add_argument("--max-tokens", type=int, default=4096,
118
+ help="Set maximum tokens for the LLM response")
119
+ parser.add_argument("--language", "--lang", default="en",
120
+ choices=["en", "fr", "es", "de", "it", "ru", "multilingual"],
121
+ help="Voice language (en=English, fr=French, es=Spanish, de=German, it=Italian, ru=Russian, multilingual=All)")
122
+ parser.add_argument("--tts-model",
123
+ help="Specific TTS model to use (overrides language default)")
124
+ return parser.parse_args()
125
+
126
+ def main():
127
+ """Entry point for AbstractVoice CLI."""
128
+ try:
129
+ # Parse command line arguments
130
+ args = parse_args()
131
+
132
+ # Handle special commands and examples
133
+ if args.command == "check-deps":
134
+ from abstractvoice.dependency_check import check_dependencies
135
+ try:
136
+ check_dependencies(verbose=True)
137
+ except Exception as e:
138
+ print(f"❌ Error running dependency check: {e}")
139
+ print("This might indicate a dependency issue.")
140
+ if args.debug:
141
+ import traceback
142
+ traceback.print_exc()
143
+ return
144
+ elif args.command == "cli":
145
+ # Import and run CLI REPL example
146
+ repl = VoiceREPL(
147
+ api_url=args.api,
148
+ model=args.model,
149
+ debug_mode=args.debug,
150
+ language=args.language,
151
+ tts_model=args.tts_model
152
+ )
153
+ # Set temperature and max_tokens
154
+ repl.temperature = args.temperature
155
+ repl.max_tokens = args.max_tokens
156
+ if args.system:
157
+ repl.system_prompt = args.system
158
+ repl.messages = [{"role": "system", "content": args.system}]
159
+ repl.cmdloop()
160
+ return
161
+ elif args.command == "web":
162
+ from abstractvoice.examples.web_api import main as web_main
163
+ web_main()
164
+ return
165
+ elif args.command == "simple":
166
+ simple_example()
167
+ return
168
+ elif args.command == "help" or args.command == "--help":
169
+ print_examples()
170
+ return
171
+ elif args.command:
172
+ print(f"Unknown command: {args.command}")
173
+ print_examples()
174
+ return
175
+
176
+ # Show language information
177
+ language_names = {
178
+ 'en': 'English', 'fr': 'French', 'es': 'Spanish',
179
+ 'de': 'German', 'it': 'Italian', 'ru': 'Russian',
180
+ 'multilingual': 'Multilingual'
181
+ }
182
+ lang_name = language_names.get(args.language, args.language)
183
+ print(f"Starting AbstractVoice voice interface ({lang_name})...")
184
+
185
+ # Initialize REPL with language support
186
+ repl = VoiceREPL(
187
+ api_url=args.api,
188
+ model=args.model,
189
+ debug_mode=args.debug,
190
+ language=args.language,
191
+ tts_model=args.tts_model
192
+ )
193
+
194
+ # Set custom system prompt if provided
195
+ if args.system:
196
+ repl.system_prompt = args.system
197
+ repl.messages = [{"role": "system", "content": args.system}]
198
+ if args.debug:
199
+ print(f"System prompt set to: {args.system}")
200
+
201
+ # Set temperature and max_tokens
202
+ repl.temperature = args.temperature
203
+ repl.max_tokens = args.max_tokens
204
+ if args.debug:
205
+ print(f"Temperature: {args.temperature}")
206
+ print(f"Max tokens: {args.max_tokens}")
207
+
208
+ # Change Whisper model if specified
209
+ if args.whisper and args.whisper != "tiny":
210
+ if repl.voice_manager.set_whisper(args.whisper):
211
+ if args.debug:
212
+ print(f"Using Whisper model: {args.whisper}")
213
+
214
+ # Start in voice mode automatically unless --no-listening is specified
215
+ if not args.no_listening:
216
+ print("Activating voice mode. Say 'stop' to exit voice mode.")
217
+ # Use the existing voice mode method
218
+ repl.do_voice("on")
219
+
220
+ # Start the REPL
221
+ repl.cmdloop()
222
+
223
+ except KeyboardInterrupt:
224
+ print("\nExiting AbstractVoice...")
225
+ except Exception as e:
226
+ error_msg = str(e).lower()
227
+ if "model file not found" in error_msg or "no such file" in error_msg:
228
+ print(f"❌ Model '{args.model}' not found")
229
+ print(f" The model file is missing or not fully downloaded")
230
+ print(f" Try: ollama pull {args.model}")
231
+ print(f" Or check available models: ollama list")
232
+ elif "connection" in error_msg or "refused" in error_msg:
233
+ print(f"❌ Cannot connect to Ollama")
234
+ print(f" Make sure Ollama is running: ollama serve")
235
+ print(f" API URL: {args.api}")
236
+ elif "importerror" in error_msg or "no module" in error_msg:
237
+ print(f"❌ Missing dependencies")
238
+ print(f" Try running: abstractvoice check-deps")
239
+ print(f" Or install dependencies: pip install abstractvoice[voice-full]")
240
+ else:
241
+ print(f"❌ Application error: {e}")
242
+ print(f" Try running with --debug for more details")
243
+
244
+ if args.debug:
245
+ import traceback
246
+ traceback.print_exc()
247
+
248
+ if __name__ == "__main__":
249
+ main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: abstractvoice
3
- Version: 0.2.1
3
+ Version: 0.3.0
4
4
  Summary: A modular Python library for voice interactions with AI systems
5
5
  Author-email: Laurent-Philippe Albou <contact@abstractcore.ai>
6
6
  License-Expression: MIT
@@ -364,14 +364,40 @@ abstractvoice --debug --whisper base --model gemma3:latest --api http://localhos
364
364
  - **Note**: This creates a "TTS-only" mode where you type and the AI speaks back
365
365
  - `--system <prompt>` - Custom system prompt
366
366
 
367
+ ### 🎯 Complete CLI Interface (v0.3.0+)
368
+
369
+ AbstractVoice provides a unified command interface for all functionality:
370
+
371
+ ```bash
372
+ # Voice mode (default)
373
+ abstractvoice # Interactive voice mode with AI
374
+ abstractvoice --model cogito:3b # With custom Ollama model
375
+ abstractvoice --language fr # French voice mode
376
+
377
+ # Examples and utilities
378
+ abstractvoice cli # CLI REPL for text interaction
379
+ abstractvoice web # Web API server
380
+ abstractvoice simple # Simple TTS/STT demonstration
381
+ abstractvoice check-deps # Check dependency compatibility
382
+ abstractvoice help # Show available commands
383
+
384
+ # Get help
385
+ abstractvoice --help # Complete help with all options
386
+ ```
387
+
388
+ **All functionality through one command!** No more confusion between different entry points.
389
+
367
390
  ### Command-Line REPL
368
391
 
369
392
  ```bash
370
393
  # Run the CLI example (TTS ON, STT OFF)
371
- abstractvoice-cli cli
394
+ abstractvoice cli
372
395
 
373
396
  # With debug mode
374
- abstractvoice-cli cli --debug
397
+ abstractvoice cli --debug
398
+
399
+ # With specific language
400
+ abstractvoice cli --language fr
375
401
  ```
376
402
 
377
403
  #### REPL Commands
@@ -423,17 +449,17 @@ All commands must start with `/` except `stop`:
423
449
 
424
450
  ```bash
425
451
  # Run the web API example
426
- abstractvoice-cli web
452
+ abstractvoice web
427
453
 
428
454
  # With different host and port
429
- abstractvoice-cli web --host 0.0.0.0 --port 8000
455
+ abstractvoice web --host 0.0.0.0 --port 8000
430
456
  ```
431
457
 
432
458
  You can also run a simplified version that doesn't load the full models:
433
459
 
434
460
  ```bash
435
461
  # Run the web API with simulation mode
436
- abstractvoice-cli web --simulate
462
+ abstractvoice web --simulate
437
463
  ```
438
464
 
439
465
  #### Troubleshooting Web API
@@ -461,7 +487,7 @@ If you encounter issues with the web API:
461
487
 
462
488
  ```bash
463
489
  # Run the simple example
464
- abstractvoice-cli simple
490
+ abstractvoice simple
465
491
  ```
466
492
 
467
493
  ## Documentation
@@ -1,3 +1,2 @@
1
1
  [console_scripts]
2
2
  abstractvoice = abstractvoice.examples.voice_cli:main
3
- abstractvoice-cli = abstractvoice.__main__:main
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "abstractvoice"
7
- version = "0.2.1"
7
+ version = "0.3.0"
8
8
  description = "A modular Python library for voice interactions with AI systems"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -123,5 +123,4 @@ Repository = "https://github.com/lpalbou/abstractvoice"
123
123
  Documentation = "https://github.com/lpalbou/abstractvoice#readme"
124
124
 
125
125
  [project.scripts]
126
- abstractvoice = "abstractvoice.examples.voice_cli:main"
127
- abstractvoice-cli = "abstractvoice.__main__:main"
126
+ abstractvoice = "abstractvoice.examples.voice_cli:main"
@@ -1,99 +0,0 @@
1
- #!/usr/bin/env python3
2
- """
3
- AbstractVoice voice mode CLI launcher.
4
-
5
- This module provides a direct entry point to start AbstractVoice in voice mode.
6
- """
7
-
8
- import argparse
9
- import time
10
- from abstractvoice.examples.cli_repl import VoiceREPL
11
-
12
- def parse_args():
13
- """Parse command line arguments."""
14
- parser = argparse.ArgumentParser(description="AbstractVoice Voice Mode")
15
- parser.add_argument("--debug", action="store_true", help="Enable debug mode")
16
- parser.add_argument("--api", default="http://localhost:11434/api/chat",
17
- help="LLM API URL")
18
- parser.add_argument("--model", default="granite3.3:2b",
19
- help="LLM model name")
20
- parser.add_argument("--whisper", default="tiny",
21
- help="Whisper model to use (tiny, base, small, medium, large)")
22
- parser.add_argument("--no-listening", action="store_true",
23
- help="Disable speech-to-text (listening), TTS still works")
24
- parser.add_argument("--system",
25
- help="Custom system prompt")
26
- parser.add_argument("--temperature", type=float, default=0.4,
27
- help="Set temperature (0.0-2.0) for the LLM")
28
- parser.add_argument("--max-tokens", type=int, default=4096,
29
- help="Set maximum tokens for the LLM response")
30
- parser.add_argument("--language", "--lang", default="en",
31
- choices=["en", "fr", "es", "de", "it", "ru", "multilingual"],
32
- help="Voice language (en=English, fr=French, es=Spanish, de=German, it=Italian, ru=Russian, multilingual=All)")
33
- parser.add_argument("--tts-model",
34
- help="Specific TTS model to use (overrides language default)")
35
- return parser.parse_args()
36
-
37
- def main():
38
- """Entry point for direct voice mode."""
39
- try:
40
- # Parse command line arguments
41
- args = parse_args()
42
-
43
- # Show language information
44
- language_names = {
45
- 'en': 'English', 'fr': 'French', 'es': 'Spanish',
46
- 'de': 'German', 'it': 'Italian', 'ru': 'Russian',
47
- 'multilingual': 'Multilingual'
48
- }
49
- lang_name = language_names.get(args.language, args.language)
50
- print(f"Starting AbstractVoice voice interface ({lang_name})...")
51
-
52
- # Initialize REPL with language support
53
- repl = VoiceREPL(
54
- api_url=args.api,
55
- model=args.model,
56
- debug_mode=args.debug,
57
- language=args.language,
58
- tts_model=args.tts_model
59
- )
60
-
61
- # Set custom system prompt if provided
62
- if args.system:
63
- repl.system_prompt = args.system
64
- repl.messages = [{"role": "system", "content": args.system}]
65
- if args.debug:
66
- print(f"System prompt set to: {args.system}")
67
-
68
- # Set temperature and max_tokens
69
- repl.temperature = args.temperature
70
- repl.max_tokens = args.max_tokens
71
- if args.debug:
72
- print(f"Temperature: {args.temperature}")
73
- print(f"Max tokens: {args.max_tokens}")
74
-
75
- # Change Whisper model if specified
76
- if args.whisper and args.whisper != "tiny":
77
- if repl.voice_manager.set_whisper(args.whisper):
78
- if args.debug:
79
- print(f"Using Whisper model: {args.whisper}")
80
-
81
- # Start in voice mode automatically unless --no-listening is specified
82
- if not args.no_listening:
83
- print("Activating voice mode. Say 'stop' to exit voice mode.")
84
- # Use the existing voice mode method
85
- repl.do_voice("on")
86
-
87
- # Start the REPL
88
- repl.cmdloop()
89
-
90
- except KeyboardInterrupt:
91
- print("\nExiting AbstractVoice...")
92
- except Exception as e:
93
- print(f"Application error: {e}")
94
- if args.debug:
95
- import traceback
96
- traceback.print_exc()
97
-
98
- if __name__ == "__main__":
99
- main()
File without changes
File without changes