Skip to content

Commit 7da0e7b

Browse files
Update README.md
Updated README.md with the additional info: Overview, testing and troubleshooting steps
1 parent 1e1afa6 commit 7da0e7b

File tree

1 file changed

+79
-2
lines changed

1 file changed

+79
-2
lines changed

README.md

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,79 @@
1-
# brave-chatgpt-stt-script
2-
A lightweight Python cloud script for voice typing and speech-to-text (STT) automation in Brave and ChatGPT, utilizing xdtool. While this script is primarily designed for desktop environments, similar functionality can be achieved on mobile devices (iOS and Android) using built-in voice dictation features or custom mobile app development
1+
# Heading 1 brave-chatgpt-stt-script (Linux web)
2+
3+
## Heading 2 This is a lightweight Python cloud script for voice typing and speech-to-text (STT) automation in Brave and ChatGPT, utilizing xdtool.
4+
5+
## Heading 2 Voice Typing Script Overview
6+
7+
While this script is primarily designed for desktop environments, similar functionality can be achieved on mobile devices (iOS and Android) using built-in voice dictation features or custom mobile app development
8+
9+
## Heading 3 Example
10+
11+
12+
### Install Necessary Dependencies
13+
Make sure you have these installed via the terminal:
14+
15+
16+
```bash
17+
sudo apt-get install python3 python3-pip xdotool portaudio19-dev python3-pyaudio
18+
pip3 install SpeechRecognition
19+
```
20+
21+
22+
Python Script
23+
Create a file named voice_type.py and add the following code:
24+
25+
```
26+
Python
27+
import speech_recognition as sr
28+
import subprocess
29+
30+
r = sr.Recognizer()
31+
mic = sr.Microphone(device_index=5) # Adjust this if needed
32+
33+
print("Starting voice typing. Press Ctrl+C to stop.\n")
34+
35+
while True:
36+
try:
37+
with mic as source:
38+
print("Please speak now...")
39+
r.adjust_for_ambient_noise(source, duration=1)
40+
audio_data = r.listen(source)
41+
42+
recognized_text = r.recognize_google(audio_data)
43+
print("You said:", recognized_text)
44+
45+
subprocess.run(["xdotool", "type", recognized_text])
46+
subprocess.run(["xdotool", "key", "space"])
47+
48+
except sr.UnknownValueError:
49+
print("Didn't catch that. Try again.")
50+
except sr.RequestError as e:
51+
print("API unreachable or error:", e)
52+
except KeyboardInterrupt:
53+
print("\nExiting...")
54+
break```
55+
56+
57+
Running the Script
58+
59+
Save the file as voice_type.py. Open the terminal and run the script:
60+
61+
```bash
62+
#python3 voice_type.py
63+
64+
Testing
65+
66+
1. Open Brave or any text editor, and run the script.
67+
2. Focus on the text field and speak into your microphone. The words should be typed automatically.
68+
69+
**Common Troubleshooting*
70+
**
71+
- If it's not working, try adjusting the device index in the script to match your active microphone (check with arecord -l).
72+
- If you encounter errors with the microphone, ensure that PulseAudio is running correctly (pulseaudio --start).
73+
Test the microphone in the terminal to ensure it's working using:
74+
75+
```
76+
bash
77+
arecord -D plughw:1,0 -f cd test-mic.wav```
78+
Commit your changes: Enter a commit message like "Add Voice Typing Script Overview" and click "Commit changes".
79+

0 commit comments

Comments
 (0)