abstractvoice 0.2.1__py3-none-any.whl → 0.3.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.
@@ -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()
@@ -9,9 +9,98 @@ import argparse
9
9
  import time
10
10
  from abstractvoice.examples.cli_repl import VoiceREPL
11
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
+
12
96
  def parse_args():
13
97
  """Parse command line arguments."""
14
- parser = argparse.ArgumentParser(description="AbstractVoice Voice Mode")
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
15
104
  parser.add_argument("--debug", action="store_true", help="Enable debug mode")
16
105
  parser.add_argument("--api", default="http://localhost:11434/api/chat",
17
106
  help="LLM API URL")
@@ -35,11 +124,55 @@ def parse_args():
35
124
  return parser.parse_args()
36
125
 
37
126
  def main():
38
- """Entry point for direct voice mode."""
127
+ """Entry point for AbstractVoice CLI."""
39
128
  try:
40
129
  # Parse command line arguments
41
130
  args = parse_args()
42
-
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
+
43
176
  # Show language information
44
177
  language_names = {
45
178
  'en': 'English', 'fr': 'French', 'es': 'Spanish',
@@ -90,7 +223,24 @@ def main():
90
223
  except KeyboardInterrupt:
91
224
  print("\nExiting AbstractVoice...")
92
225
  except Exception as e:
93
- print(f"Application error: {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
+
94
244
  if args.debug:
95
245
  import traceback
96
246
  traceback.print_exc()
@@ -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
@@ -4,8 +4,8 @@ abstractvoice/dependency_check.py,sha256=BUUADz4un4_FCZzNpgwk1qpJ6yqVi5Pvjfd3JLS
4
4
  abstractvoice/recognition.py,sha256=4KtDUDFixEYuBUMDH2fWaD9csKlwA9tqXkMAkyQMSMo,11259
5
5
  abstractvoice/voice_manager.py,sha256=WYuN949pzf4pw8SE3g40OQZNC1CbgUZ5SzvpAGAIfPI,29995
6
6
  abstractvoice/examples/__init__.py,sha256=94vpKJDlfOrEBIUETg-57Q5Z7fYDidg6v4UzV7V_lZA,60
7
- abstractvoice/examples/cli_repl.py,sha256=uRFqUOVDP6RXrMquB_rQ1_fxdyLn_UHwuiu30XHbYwE,41250
8
- abstractvoice/examples/voice_cli.py,sha256=mhiO7i0AooPWPZD-K6O-wQUvMFbRFED-dlGNUjDvsUE,3962
7
+ abstractvoice/examples/cli_repl.py,sha256=39KO2zbQCG3bkuzrMEp1txLherw2rU4aGG2KTUHBYW0,42636
8
+ abstractvoice/examples/voice_cli.py,sha256=oliUPUZUPR6HaVaOtn-vAM-Loq3PDqkP34w-X3xxzbY,9702
9
9
  abstractvoice/examples/web_api.py,sha256=0g5LKJpl7fZepPQJL25AcdaevV-xv34VqqyWGYYchPk,6376
10
10
  abstractvoice/stt/__init__.py,sha256=PFc6la3tTkxT4TJYwb0PnMIahM_hFtU4pNQdeKmbooo,120
11
11
  abstractvoice/stt/transcriber.py,sha256=GdaH1OsCHu4Vu9rUsQlzH6X9bfcnoiK5tGz1AW_uj6Q,5481
@@ -13,9 +13,9 @@ abstractvoice/tts/__init__.py,sha256=WgJrxqdc_qaRyfFt1jbgMQD9S757jYuBpDzMRB02TFs
13
13
  abstractvoice/tts/tts_engine.py,sha256=9CZAZITZ_VNZs0grwsqWIFj3aUsHvrWeFVV66lH_Bf8,44926
14
14
  abstractvoice/vad/__init__.py,sha256=RIIbFw25jNHgel06E4VvTWJnXjwjeFZ98m1Vx9hVjuo,119
15
15
  abstractvoice/vad/voice_detector.py,sha256=ghrhpDFlIR5TsMB2gpigXY6t5c_1yZ7vEX1imAMgWjc,3166
16
- abstractvoice-0.2.1.dist-info/licenses/LICENSE,sha256=TiDPM5WcFRQPoC5e46jGMeMppZ-eu0eFx_HytjE49bk,1105
17
- abstractvoice-0.2.1.dist-info/METADATA,sha256=KFp786KB4_KECTUvlTdWgvLkiTPXhrHhJup9huRAESs,37533
18
- abstractvoice-0.2.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
- abstractvoice-0.2.1.dist-info/entry_points.txt,sha256=rL63lqtLrbd7w_hGsR_w9Mr5baq4p3Mzwn4_UJqR_nI,120
20
- abstractvoice-0.2.1.dist-info/top_level.txt,sha256=a1qyxqgF1O8cJtPKpcJuImGZ_uXqPNghbLZ9gp-UiOo,14
21
- abstractvoice-0.2.1.dist-info/RECORD,,
16
+ abstractvoice-0.3.0.dist-info/licenses/LICENSE,sha256=TiDPM5WcFRQPoC5e46jGMeMppZ-eu0eFx_HytjE49bk,1105
17
+ abstractvoice-0.3.0.dist-info/METADATA,sha256=_XLernZJC91kjzhBMIecBMN4bWcd2AerbPZ8rOmwFIc,38420
18
+ abstractvoice-0.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
+ abstractvoice-0.3.0.dist-info/entry_points.txt,sha256=3bDX2dNOGvrsTx1wZ_o_hVgmM_a2zbcHc1ZkL154rN4,72
20
+ abstractvoice-0.3.0.dist-info/top_level.txt,sha256=a1qyxqgF1O8cJtPKpcJuImGZ_uXqPNghbLZ9gp-UiOo,14
21
+ abstractvoice-0.3.0.dist-info/RECORD,,
@@ -1,3 +1,2 @@
1
1
  [console_scripts]
2
2
  abstractvoice = abstractvoice.examples.voice_cli:main
3
- abstractvoice-cli = abstractvoice.__main__:main