-
Notifications
You must be signed in to change notification settings - Fork 397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Websocket transport #81
Conversation
336b8fc
to
94db395
Compare
e393eaa
to
93e62c4
Compare
4405f7c
to
695d060
Compare
|
||
for (let i = 0; i < frameCount; i++) { | ||
const word = view[i]; | ||
nowBuffering[i] = ((word + 32768) % 65536 - 32768) / 32768.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems nowBuffering
is not being used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nm, you are modifying the contents.
self._stop_server_event.set() | ||
break | ||
if self._websocket and frame: | ||
proto = frame.to_proto().SerializeToString() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we would then do
proto = self._serializer.serialize(frame)
and we would have:
self._serializer = ProtobufFrameSerializer()
self._websocket = websocket | ||
async for message in websocket: | ||
generic_frame = frame_protos.Frame.FromString(message) | ||
frame = FrameFromProto(generic_frame) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of the two lines above we would have:
frame = self._serializer.deserialize(message)
I will review more tomorrow but I'm wondering if we should have a serializer classe instead. Something like:
and then:
then we could even pass that to the transport:
but we should be able to call it with:
for example. Or something like this. |
This looks very good. Just adding talking out loud and adding some first thoughts. 🙌 . |
I like the Serializer idea, will play with that this morning. |
Okay, added the serializer class. I can't tell if I went too far with the abstraction, but it now dynamically discovers the fields and transfers them. This reduces the code, overall, and requires the protobuf field names to match the Frame field names. I think this is okay (or even good), but it made me realize that I could also dynamically create the .proto file from the Frames.py file. I didn't go that far. |
Nice! Yes, perfect, no need for additional I'll take a final look in a bit, but I think this looks great! Thank you for making the changes! |
args: --exit-code -r -d -a -a src/ | ||
run: | | ||
source .venv/bin/activate | ||
autopep8 --max-line-length 100 --exit-code -r -d --exclude "*_pb2.py" -a -a src/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hahahaha. OK.... but what will we do in 2040?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by then my vision will be bad enough that I'll lobby we go back to 80 columns 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh... we should update the README with this setting.
self._n_channels = kwargs.get("n_channels", 1) | ||
self._port = kwargs.get("port", 8765) | ||
self._host = kwargs.get("host", "localhost") | ||
self._audio_frame_size = kwargs.get("audio_frame_size", 16000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This 16000 seems to match the value from WebSocketFrameProcessor
, maybe a constant for both would be nice.
TextFrame, AudioFrame, TTSEndFrame, TTSStartFrame]) | ||
self._serializer = kwargs.get("serializer", ProtobufFrameSerializer()) | ||
|
||
if self._camera_enabled: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is _camera_enabled
defined?
raise ValueError( | ||
"Camera is not supported in WebsocketTransportService") | ||
|
||
if self._speaker_enabled: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems _speaker_buffer_pending
is not used. so maybe these too blocks are not needed? seems a transport should need to care about speaker or camera.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, this comes from the base class....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but i believe the comment about transport not caring about cameras or microphone still applies... This might be related to your other comment of separating transport from services. I think it makes total sense.
LGTM! Just added a comment about a constant and some question/comment that I believe you were also suggesting. |
@@ -152,6 +152,7 @@ Install the | |||
}, | |||
"autopep8.args": [ | |||
"-a", | |||
"-a" | |||
"-a", | |||
"--max-line-length=100" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the =
work? If so, use that on Emacs as well.
d9a6af0
to
2bda4c3
Compare
This PR introduces a WebSocketTransport class, and has a sample that implements an admittedly janky Javascript client for this transport. The sample code uses Whisper to do transcription, and it seems to work, albeit slowly.
Some notes:
Some to-dos/not yet done: