speakline 0.1.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.
- speakline-0.1.0/LICENSE +21 -0
- speakline-0.1.0/PKG-INFO +304 -0
- speakline-0.1.0/README.md +267 -0
- speakline-0.1.0/pyproject.toml +80 -0
- speakline-0.1.0/setup.cfg +4 -0
- speakline-0.1.0/speakline.egg-info/PKG-INFO +304 -0
- speakline-0.1.0/speakline.egg-info/SOURCES.txt +19 -0
- speakline-0.1.0/speakline.egg-info/dependency_links.txt +1 -0
- speakline-0.1.0/speakline.egg-info/entry_points.txt +2 -0
- speakline-0.1.0/speakline.egg-info/requires.txt +13 -0
- speakline-0.1.0/speakline.egg-info/top_level.txt +1 -0
- speakline-0.1.0/tests/test_commenter.py +210 -0
- speakline-0.1.0/tests/test_parser.py +287 -0
- speakline-0.1.0/tests/test_recorder.py +100 -0
- speakline-0.1.0/tests/test_transcriber.py +75 -0
- speakline-0.1.0/voicecomment/__init__.py +98 -0
- speakline-0.1.0/voicecomment/cli.py +250 -0
- speakline-0.1.0/voicecomment/commenter.py +267 -0
- speakline-0.1.0/voicecomment/parser.py +462 -0
- speakline-0.1.0/voicecomment/recorder.py +297 -0
- speakline-0.1.0/voicecomment/transcriber.py +293 -0
speakline-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 VoiceComment
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
speakline-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: speakline
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Record voice and insert as inline code comments across any language and IDE
|
|
5
|
+
Author: VoiceComment Team
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/likthvishal/SpeakLine
|
|
8
|
+
Project-URL: Repository, https://github.com/likthvishal/SpeakLine
|
|
9
|
+
Project-URL: Issues, https://github.com/likthvishal/SpeakLine/issues
|
|
10
|
+
Keywords: voice,comments,code,transcription,whisper,developer-tools
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Documentation
|
|
20
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: pyaudio>=0.2.13
|
|
25
|
+
Requires-Dist: numpy>=1.24.0
|
|
26
|
+
Requires-Dist: openai-whisper>=20231117
|
|
27
|
+
Requires-Dist: openai>=1.0.0
|
|
28
|
+
Requires-Dist: typer>=0.9.0
|
|
29
|
+
Requires-Dist: rich>=13.0.0
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
32
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
33
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
34
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
35
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
# VoiceComment
|
|
39
|
+
|
|
40
|
+
**Record voice and insert as inline code comments across any language and IDE.**
|
|
41
|
+
|
|
42
|
+
Turn your spoken thoughts into well-formatted code comments with a single command. Works with Python, JavaScript, TypeScript, Go, Rust, Java, and more.
|
|
43
|
+
|
|
44
|
+

|
|
45
|
+

|
|
46
|
+

|
|
47
|
+
|
|
48
|
+
## Features
|
|
49
|
+
|
|
50
|
+
- **Voice Recording**: Local microphone input with silence detection
|
|
51
|
+
- **Transcription**: Support for Whisper (local) and OpenAI API
|
|
52
|
+
- **Smart Comment Insertion**: Language-aware parser with proper indentation
|
|
53
|
+
- **Multi-Language Support**: Python, JavaScript, TypeScript, Go, Rust, Java, C#, Ruby
|
|
54
|
+
- **Pluggable Backends**: Swap recorders, transcribers, and parsers easily
|
|
55
|
+
- **Flexible API**: CLI, Python package, and programmatic access
|
|
56
|
+
- **Production-Ready**: Type hints, error handling, and comprehensive logging
|
|
57
|
+
|
|
58
|
+
## Installation
|
|
59
|
+
|
|
60
|
+
### Prerequisites
|
|
61
|
+
- Python 3.9+
|
|
62
|
+
- PortAudio (for audio recording)
|
|
63
|
+
|
|
64
|
+
### macOS
|
|
65
|
+
```bash
|
|
66
|
+
brew install portaudio
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Ubuntu/Debian
|
|
70
|
+
```bash
|
|
71
|
+
sudo apt-get install portaudio19-dev
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Windows
|
|
75
|
+
PortAudio is typically bundled. If not, download from [PortAudio Downloads](http://www.portaudio.com/download.html).
|
|
76
|
+
|
|
77
|
+
### Install Package
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pip install voicecomment
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Or from source (development):
|
|
84
|
+
```bash
|
|
85
|
+
git clone https://github.com/yourusername/voicecomment
|
|
86
|
+
cd voicecomment
|
|
87
|
+
pip install -e .
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Quick Start
|
|
91
|
+
|
|
92
|
+
### Command Line
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# Record and insert comment at line 42
|
|
96
|
+
voicecomment record myfile.py 42
|
|
97
|
+
|
|
98
|
+
# With fixed duration (5 seconds)
|
|
99
|
+
voicecomment record myfile.py 42 --duration 5
|
|
100
|
+
|
|
101
|
+
# Transcribe without modifying file
|
|
102
|
+
voicecomment transcribe
|
|
103
|
+
|
|
104
|
+
# Insert comment directly (no recording)
|
|
105
|
+
voicecomment insert myfile.py 42 "This is my comment"
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Python API
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
from voicecomment import VoiceCommenter
|
|
112
|
+
|
|
113
|
+
# Auto-detect language from file extension
|
|
114
|
+
commenter = VoiceCommenter()
|
|
115
|
+
commenter.record_and_insert('myfile.py', line_number=42)
|
|
116
|
+
|
|
117
|
+
# Or specify language explicitly
|
|
118
|
+
commenter = VoiceCommenter(language='python')
|
|
119
|
+
commenter.record_and_insert('main.py', line_number=15)
|
|
120
|
+
|
|
121
|
+
# Transcribe only
|
|
122
|
+
text = commenter.transcribe_only()
|
|
123
|
+
print(text) # "This function calculates factorial recursively"
|
|
124
|
+
|
|
125
|
+
# Insert into code string (no file I/O)
|
|
126
|
+
code = """
|
|
127
|
+
def factorial(n):
|
|
128
|
+
return n * factorial(n - 1) if n > 1 else 1
|
|
129
|
+
"""
|
|
130
|
+
updated = commenter.insert_comment_to_string(
|
|
131
|
+
code,
|
|
132
|
+
"Base case for recursion",
|
|
133
|
+
line_number=3
|
|
134
|
+
)
|
|
135
|
+
print(updated)
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Jupyter Notebook
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
from voicecomment import VoiceCommenter
|
|
142
|
+
|
|
143
|
+
commenter = VoiceCommenter(language='python')
|
|
144
|
+
|
|
145
|
+
# Record and modify cell code
|
|
146
|
+
code_str = """
|
|
147
|
+
def process_data(df):
|
|
148
|
+
return df.dropna()
|
|
149
|
+
"""
|
|
150
|
+
|
|
151
|
+
updated = commenter.insert_comment_to_string(
|
|
152
|
+
code_str,
|
|
153
|
+
"Remove rows with missing values",
|
|
154
|
+
line_number=2
|
|
155
|
+
)
|
|
156
|
+
print(updated)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Architecture
|
|
160
|
+
|
|
161
|
+
### Core Components
|
|
162
|
+
|
|
163
|
+
#### 1. **AudioRecorder** (`recorder.py`)
|
|
164
|
+
- `LocalAudioRecorder`: Captures audio from system microphone
|
|
165
|
+
- Supports fixed duration or silence detection
|
|
166
|
+
- Configurable sample rate, channels, and format
|
|
167
|
+
|
|
168
|
+
#### 2. **Transcriber** (`transcriber.py`)
|
|
169
|
+
Pluggable backends:
|
|
170
|
+
- `WhisperTranscriber`: Local OpenAI Whisper model (no API key needed)
|
|
171
|
+
- `OpenAITranscriber`: OpenAI Whisper API
|
|
172
|
+
- `MockTranscriber`: For testing without audio hardware
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
# Use local Whisper
|
|
176
|
+
from voicecomment.transcriber import WhisperTranscriber
|
|
177
|
+
transcriber = WhisperTranscriber(model_size="base")
|
|
178
|
+
|
|
179
|
+
# Or OpenAI API
|
|
180
|
+
from voicecomment.transcriber import OpenAITranscriber
|
|
181
|
+
transcriber = OpenAITranscriber(api_key="sk-...")
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### 3. **CodeParser** (`parser.py`)
|
|
185
|
+
Language-specific parsers:
|
|
186
|
+
- `PythonParser`: Uses `#` prefix with proper indentation
|
|
187
|
+
- `JavaScriptParser`: Uses `//` prefix
|
|
188
|
+
- `GenericParser`: Configurable fallback for unsupported languages
|
|
189
|
+
|
|
190
|
+
#### 4. **VoiceCommenter** (`commenter.py`)
|
|
191
|
+
Main orchestration class that ties everything together.
|
|
192
|
+
|
|
193
|
+
## Advanced Usage
|
|
194
|
+
|
|
195
|
+
### Custom Transcriber
|
|
196
|
+
|
|
197
|
+
```python
|
|
198
|
+
from voicecomment import VoiceCommenter
|
|
199
|
+
from voicecomment.transcriber import TranscriberBase
|
|
200
|
+
import numpy as np
|
|
201
|
+
|
|
202
|
+
class CustomLLMTranscriber(TranscriberBase):
|
|
203
|
+
def transcribe(self, audio: np.ndarray, sample_rate: int = 16000) -> str:
|
|
204
|
+
# Your LLM logic here
|
|
205
|
+
return "custom transcription"
|
|
206
|
+
|
|
207
|
+
commenter = VoiceCommenter(transcriber=CustomLLMTranscriber())
|
|
208
|
+
commenter.record_and_insert('file.py', line_number=10)
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Custom Audio Config
|
|
212
|
+
|
|
213
|
+
```python
|
|
214
|
+
from voicecomment import VoiceCommenter, AudioConfig
|
|
215
|
+
|
|
216
|
+
config = AudioConfig(
|
|
217
|
+
sample_rate=44100, # High-quality audio
|
|
218
|
+
channels=2, # Stereo
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
commenter = VoiceCommenter(audio_config=config)
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Integration with IDE Extensions
|
|
225
|
+
|
|
226
|
+
The Python package can be called from:
|
|
227
|
+
- **VS Code Extension**: Via subprocess or Node.js child process
|
|
228
|
+
- **Vim Plugin**: Via Python 3 interface
|
|
229
|
+
- **Neovim**: Via Python plugin host
|
|
230
|
+
- **Emacs**: Via `python-shell`
|
|
231
|
+
|
|
232
|
+
Example VS Code extension (snippet):
|
|
233
|
+
```typescript
|
|
234
|
+
const { spawn } = require('child_process');
|
|
235
|
+
|
|
236
|
+
const proc = spawn('voicecomment', ['record', filepath, lineNumber.toString()]);
|
|
237
|
+
proc.on('close', (code) => {
|
|
238
|
+
if (code === 0) {
|
|
239
|
+
vscode.window.showInformationMessage('Comment inserted!');
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Development
|
|
245
|
+
|
|
246
|
+
### Setup
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
git clone https://github.com/yourusername/voicecomment
|
|
250
|
+
cd voicecomment
|
|
251
|
+
pip install -e ".[dev]"
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Testing
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
pytest
|
|
258
|
+
pytest --cov # With coverage
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Code Quality
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
black .
|
|
265
|
+
ruff check .
|
|
266
|
+
mypy voicecomment/
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## Supported Languages
|
|
270
|
+
|
|
271
|
+
| Language | Extension | Comment Prefix |
|
|
272
|
+
|----------|-----------|----------------|
|
|
273
|
+
| Python | `.py`, `.pyw` | `#` |
|
|
274
|
+
| JavaScript | `.js`, `.jsx`, `.mjs` | `//` |
|
|
275
|
+
| TypeScript | `.ts`, `.tsx`, `.mts` | `//` |
|
|
276
|
+
| Go | `.go` | `//` |
|
|
277
|
+
| Rust | `.rs` | `//` |
|
|
278
|
+
| Java | `.java` | `//` |
|
|
279
|
+
| C# | `.cs` | `//` |
|
|
280
|
+
| Ruby | `.rb` | `#` |
|
|
281
|
+
| C/C++ | `.c`, `.cpp`, `.h`, `.hpp` | `//` |
|
|
282
|
+
|
|
283
|
+
## Roadmap
|
|
284
|
+
|
|
285
|
+
- [ ] VS Code Extension (official)
|
|
286
|
+
- [ ] Vim/Neovim plugin
|
|
287
|
+
- [ ] Watch mode for automated comment markers
|
|
288
|
+
- [ ] Voice activity detection (VAD)
|
|
289
|
+
- [ ] Conversation-aware transcription (context from file)
|
|
290
|
+
- [ ] Custom prompt engineering for comment style
|
|
291
|
+
- [ ] Analytics dashboard (tracking comment patterns)
|
|
292
|
+
- [ ] LangChain integration for LLM-powered comments
|
|
293
|
+
|
|
294
|
+
## Contributing
|
|
295
|
+
|
|
296
|
+
Contributions welcome! Please open an issue or pull request.
|
|
297
|
+
|
|
298
|
+
## License
|
|
299
|
+
|
|
300
|
+
MIT License - see [LICENSE](LICENSE)
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
**Built for developers who believe code comments should be as natural as talking.**
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
# VoiceComment
|
|
2
|
+
|
|
3
|
+
**Record voice and insert as inline code comments across any language and IDE.**
|
|
4
|
+
|
|
5
|
+
Turn your spoken thoughts into well-formatted code comments with a single command. Works with Python, JavaScript, TypeScript, Go, Rust, Java, and more.
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **Voice Recording**: Local microphone input with silence detection
|
|
14
|
+
- **Transcription**: Support for Whisper (local) and OpenAI API
|
|
15
|
+
- **Smart Comment Insertion**: Language-aware parser with proper indentation
|
|
16
|
+
- **Multi-Language Support**: Python, JavaScript, TypeScript, Go, Rust, Java, C#, Ruby
|
|
17
|
+
- **Pluggable Backends**: Swap recorders, transcribers, and parsers easily
|
|
18
|
+
- **Flexible API**: CLI, Python package, and programmatic access
|
|
19
|
+
- **Production-Ready**: Type hints, error handling, and comprehensive logging
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
### Prerequisites
|
|
24
|
+
- Python 3.9+
|
|
25
|
+
- PortAudio (for audio recording)
|
|
26
|
+
|
|
27
|
+
### macOS
|
|
28
|
+
```bash
|
|
29
|
+
brew install portaudio
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Ubuntu/Debian
|
|
33
|
+
```bash
|
|
34
|
+
sudo apt-get install portaudio19-dev
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Windows
|
|
38
|
+
PortAudio is typically bundled. If not, download from [PortAudio Downloads](http://www.portaudio.com/download.html).
|
|
39
|
+
|
|
40
|
+
### Install Package
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install voicecomment
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Or from source (development):
|
|
47
|
+
```bash
|
|
48
|
+
git clone https://github.com/yourusername/voicecomment
|
|
49
|
+
cd voicecomment
|
|
50
|
+
pip install -e .
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Quick Start
|
|
54
|
+
|
|
55
|
+
### Command Line
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Record and insert comment at line 42
|
|
59
|
+
voicecomment record myfile.py 42
|
|
60
|
+
|
|
61
|
+
# With fixed duration (5 seconds)
|
|
62
|
+
voicecomment record myfile.py 42 --duration 5
|
|
63
|
+
|
|
64
|
+
# Transcribe without modifying file
|
|
65
|
+
voicecomment transcribe
|
|
66
|
+
|
|
67
|
+
# Insert comment directly (no recording)
|
|
68
|
+
voicecomment insert myfile.py 42 "This is my comment"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Python API
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from voicecomment import VoiceCommenter
|
|
75
|
+
|
|
76
|
+
# Auto-detect language from file extension
|
|
77
|
+
commenter = VoiceCommenter()
|
|
78
|
+
commenter.record_and_insert('myfile.py', line_number=42)
|
|
79
|
+
|
|
80
|
+
# Or specify language explicitly
|
|
81
|
+
commenter = VoiceCommenter(language='python')
|
|
82
|
+
commenter.record_and_insert('main.py', line_number=15)
|
|
83
|
+
|
|
84
|
+
# Transcribe only
|
|
85
|
+
text = commenter.transcribe_only()
|
|
86
|
+
print(text) # "This function calculates factorial recursively"
|
|
87
|
+
|
|
88
|
+
# Insert into code string (no file I/O)
|
|
89
|
+
code = """
|
|
90
|
+
def factorial(n):
|
|
91
|
+
return n * factorial(n - 1) if n > 1 else 1
|
|
92
|
+
"""
|
|
93
|
+
updated = commenter.insert_comment_to_string(
|
|
94
|
+
code,
|
|
95
|
+
"Base case for recursion",
|
|
96
|
+
line_number=3
|
|
97
|
+
)
|
|
98
|
+
print(updated)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Jupyter Notebook
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from voicecomment import VoiceCommenter
|
|
105
|
+
|
|
106
|
+
commenter = VoiceCommenter(language='python')
|
|
107
|
+
|
|
108
|
+
# Record and modify cell code
|
|
109
|
+
code_str = """
|
|
110
|
+
def process_data(df):
|
|
111
|
+
return df.dropna()
|
|
112
|
+
"""
|
|
113
|
+
|
|
114
|
+
updated = commenter.insert_comment_to_string(
|
|
115
|
+
code_str,
|
|
116
|
+
"Remove rows with missing values",
|
|
117
|
+
line_number=2
|
|
118
|
+
)
|
|
119
|
+
print(updated)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Architecture
|
|
123
|
+
|
|
124
|
+
### Core Components
|
|
125
|
+
|
|
126
|
+
#### 1. **AudioRecorder** (`recorder.py`)
|
|
127
|
+
- `LocalAudioRecorder`: Captures audio from system microphone
|
|
128
|
+
- Supports fixed duration or silence detection
|
|
129
|
+
- Configurable sample rate, channels, and format
|
|
130
|
+
|
|
131
|
+
#### 2. **Transcriber** (`transcriber.py`)
|
|
132
|
+
Pluggable backends:
|
|
133
|
+
- `WhisperTranscriber`: Local OpenAI Whisper model (no API key needed)
|
|
134
|
+
- `OpenAITranscriber`: OpenAI Whisper API
|
|
135
|
+
- `MockTranscriber`: For testing without audio hardware
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
# Use local Whisper
|
|
139
|
+
from voicecomment.transcriber import WhisperTranscriber
|
|
140
|
+
transcriber = WhisperTranscriber(model_size="base")
|
|
141
|
+
|
|
142
|
+
# Or OpenAI API
|
|
143
|
+
from voicecomment.transcriber import OpenAITranscriber
|
|
144
|
+
transcriber = OpenAITranscriber(api_key="sk-...")
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
#### 3. **CodeParser** (`parser.py`)
|
|
148
|
+
Language-specific parsers:
|
|
149
|
+
- `PythonParser`: Uses `#` prefix with proper indentation
|
|
150
|
+
- `JavaScriptParser`: Uses `//` prefix
|
|
151
|
+
- `GenericParser`: Configurable fallback for unsupported languages
|
|
152
|
+
|
|
153
|
+
#### 4. **VoiceCommenter** (`commenter.py`)
|
|
154
|
+
Main orchestration class that ties everything together.
|
|
155
|
+
|
|
156
|
+
## Advanced Usage
|
|
157
|
+
|
|
158
|
+
### Custom Transcriber
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
from voicecomment import VoiceCommenter
|
|
162
|
+
from voicecomment.transcriber import TranscriberBase
|
|
163
|
+
import numpy as np
|
|
164
|
+
|
|
165
|
+
class CustomLLMTranscriber(TranscriberBase):
|
|
166
|
+
def transcribe(self, audio: np.ndarray, sample_rate: int = 16000) -> str:
|
|
167
|
+
# Your LLM logic here
|
|
168
|
+
return "custom transcription"
|
|
169
|
+
|
|
170
|
+
commenter = VoiceCommenter(transcriber=CustomLLMTranscriber())
|
|
171
|
+
commenter.record_and_insert('file.py', line_number=10)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Custom Audio Config
|
|
175
|
+
|
|
176
|
+
```python
|
|
177
|
+
from voicecomment import VoiceCommenter, AudioConfig
|
|
178
|
+
|
|
179
|
+
config = AudioConfig(
|
|
180
|
+
sample_rate=44100, # High-quality audio
|
|
181
|
+
channels=2, # Stereo
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
commenter = VoiceCommenter(audio_config=config)
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Integration with IDE Extensions
|
|
188
|
+
|
|
189
|
+
The Python package can be called from:
|
|
190
|
+
- **VS Code Extension**: Via subprocess or Node.js child process
|
|
191
|
+
- **Vim Plugin**: Via Python 3 interface
|
|
192
|
+
- **Neovim**: Via Python plugin host
|
|
193
|
+
- **Emacs**: Via `python-shell`
|
|
194
|
+
|
|
195
|
+
Example VS Code extension (snippet):
|
|
196
|
+
```typescript
|
|
197
|
+
const { spawn } = require('child_process');
|
|
198
|
+
|
|
199
|
+
const proc = spawn('voicecomment', ['record', filepath, lineNumber.toString()]);
|
|
200
|
+
proc.on('close', (code) => {
|
|
201
|
+
if (code === 0) {
|
|
202
|
+
vscode.window.showInformationMessage('Comment inserted!');
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Development
|
|
208
|
+
|
|
209
|
+
### Setup
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
git clone https://github.com/yourusername/voicecomment
|
|
213
|
+
cd voicecomment
|
|
214
|
+
pip install -e ".[dev]"
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Testing
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
pytest
|
|
221
|
+
pytest --cov # With coverage
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Code Quality
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
black .
|
|
228
|
+
ruff check .
|
|
229
|
+
mypy voicecomment/
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Supported Languages
|
|
233
|
+
|
|
234
|
+
| Language | Extension | Comment Prefix |
|
|
235
|
+
|----------|-----------|----------------|
|
|
236
|
+
| Python | `.py`, `.pyw` | `#` |
|
|
237
|
+
| JavaScript | `.js`, `.jsx`, `.mjs` | `//` |
|
|
238
|
+
| TypeScript | `.ts`, `.tsx`, `.mts` | `//` |
|
|
239
|
+
| Go | `.go` | `//` |
|
|
240
|
+
| Rust | `.rs` | `//` |
|
|
241
|
+
| Java | `.java` | `//` |
|
|
242
|
+
| C# | `.cs` | `//` |
|
|
243
|
+
| Ruby | `.rb` | `#` |
|
|
244
|
+
| C/C++ | `.c`, `.cpp`, `.h`, `.hpp` | `//` |
|
|
245
|
+
|
|
246
|
+
## Roadmap
|
|
247
|
+
|
|
248
|
+
- [ ] VS Code Extension (official)
|
|
249
|
+
- [ ] Vim/Neovim plugin
|
|
250
|
+
- [ ] Watch mode for automated comment markers
|
|
251
|
+
- [ ] Voice activity detection (VAD)
|
|
252
|
+
- [ ] Conversation-aware transcription (context from file)
|
|
253
|
+
- [ ] Custom prompt engineering for comment style
|
|
254
|
+
- [ ] Analytics dashboard (tracking comment patterns)
|
|
255
|
+
- [ ] LangChain integration for LLM-powered comments
|
|
256
|
+
|
|
257
|
+
## Contributing
|
|
258
|
+
|
|
259
|
+
Contributions welcome! Please open an issue or pull request.
|
|
260
|
+
|
|
261
|
+
## License
|
|
262
|
+
|
|
263
|
+
MIT License - see [LICENSE](LICENSE)
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
**Built for developers who believe code comments should be as natural as talking.**
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "speakline"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Record voice and insert as inline code comments across any language and IDE"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "VoiceComment Team"}
|
|
14
|
+
]
|
|
15
|
+
keywords = ["voice", "comments", "code", "transcription", "whisper", "developer-tools"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"License :: OSI Approved :: MIT License",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.9",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Topic :: Software Development :: Documentation",
|
|
26
|
+
"Topic :: Multimedia :: Sound/Audio :: Speech",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
dependencies = [
|
|
30
|
+
"pyaudio>=0.2.13",
|
|
31
|
+
"numpy>=1.24.0",
|
|
32
|
+
"openai-whisper>=20231117",
|
|
33
|
+
"openai>=1.0.0",
|
|
34
|
+
"typer>=0.9.0",
|
|
35
|
+
"rich>=13.0.0",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.optional-dependencies]
|
|
39
|
+
dev = [
|
|
40
|
+
"pytest>=7.0.0",
|
|
41
|
+
"pytest-cov>=4.0.0",
|
|
42
|
+
"black>=23.0.0",
|
|
43
|
+
"ruff>=0.1.0",
|
|
44
|
+
"mypy>=1.0.0",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[project.scripts]
|
|
48
|
+
speakline = "voicecomment.cli:app"
|
|
49
|
+
|
|
50
|
+
[project.urls]
|
|
51
|
+
Homepage = "https://github.com/likthvishal/SpeakLine"
|
|
52
|
+
Repository = "https://github.com/likthvishal/SpeakLine"
|
|
53
|
+
Issues = "https://github.com/likthvishal/SpeakLine/issues"
|
|
54
|
+
|
|
55
|
+
[tool.setuptools.packages.find]
|
|
56
|
+
where = ["."]
|
|
57
|
+
include = ["voicecomment*"]
|
|
58
|
+
|
|
59
|
+
[tool.black]
|
|
60
|
+
line-length = 100
|
|
61
|
+
target-version = ["py39", "py310", "py311", "py312"]
|
|
62
|
+
|
|
63
|
+
[tool.ruff]
|
|
64
|
+
line-length = 100
|
|
65
|
+
target-version = "py39"
|
|
66
|
+
|
|
67
|
+
[tool.ruff.lint]
|
|
68
|
+
select = ["E", "F", "W", "I", "N", "UP", "B", "C4"]
|
|
69
|
+
ignore = ["E501"]
|
|
70
|
+
|
|
71
|
+
[tool.mypy]
|
|
72
|
+
python_version = "3.9"
|
|
73
|
+
warn_return_any = true
|
|
74
|
+
warn_unused_configs = true
|
|
75
|
+
disallow_untyped_defs = true
|
|
76
|
+
|
|
77
|
+
[tool.pytest.ini_options]
|
|
78
|
+
testpaths = ["tests"]
|
|
79
|
+
python_files = ["test_*.py"]
|
|
80
|
+
addopts = "-v"
|