fix text input

This commit is contained in:
Logan Markewich
2024-10-07 21:03:49 -06:00
parent 05d3866fd6
commit 044e768c35
2 changed files with 14 additions and 8 deletions
+10 -2
View File
@@ -2,14 +2,22 @@
## Installation
Install all dependendencies:
Install system deps:
```bash
brew install ffmpeg
```
Install python deps:
```bash
pip install pyaudio pynput pydub websockets
pip install -U openai pyaudio pynput pydub websockets
```
Set your openai key:
```bash
export OPENAI_API_KEY="sk-..."
```
## Usage
+4 -6
View File
@@ -175,7 +175,6 @@ class InputHandler:
self.command_queue.put_nowait, ('enter', self.text_input)
)
self.text_input = ""
print("\nYou: ", end="", flush=True)
elif key == keyboard.KeyCode.from_char('r'):
self.loop.call_soon_threadsafe(
self.command_queue.put_nowait, ('r', None)
@@ -187,10 +186,8 @@ class InputHandler:
elif hasattr(key, 'char'):
if key == keyboard.Key.backspace:
self.text_input = self.text_input[:-1]
print('\b \b', end="", flush=True)
else:
self.text_input += key.char
print(key.char, end="", flush=True)
except AttributeError:
pass
@@ -224,8 +221,8 @@ async def main():
print("- Press 'r' to start recording audio")
print("- Press 'space' to stop recording")
print("- Press 'q' to quit")
print("\nYou: ", end="", flush=True)
print("")
while True:
# Wait for commands from the input handler
command, data = await input_handler.command_queue.get()
@@ -247,7 +244,8 @@ async def main():
elif command == 'enter' and data:
# Send text message
await client.send_text(data)
await asyncio.sleep(0.01)
except Exception as e:
print(f"Error: {e}")
finally: