Skip to content

Fix sphn API compatibility with Kyutai Labs implementation#44

Open
CharlesMcquade wants to merge 1 commit intoNVIDIA:mainfrom
CharlesMcquade:fix/sphn-api-compatibility
Open

Fix sphn API compatibility with Kyutai Labs implementation#44
CharlesMcquade wants to merge 1 commit intoNVIDIA:mainfrom
CharlesMcquade:fix/sphn-api-compatibility

Conversation

@CharlesMcquade
Copy link

The sphn package from PyPI (Kyutai Labs version) uses a different API than what PersonaPlex originally expected:

  • OpusStreamReader.append_bytes(bytes) -> returns np.ndarray PCM immediately
  • OpusStreamWriter.append_pcm(pcm) -> returns bytes Opus data immediately

This fix updates server.py to use the correct streaming API by:

  1. Buffering incoming Opus bytes in a queue
  2. Processing queue items with append_bytes() and capturing returned PCM
  3. Capturing Opus bytes returned from append_pcm() instead of calling read_bytes()

This resolves the AttributeError crashes on client connections:

  • 'OpusStreamReader' object has no attribute 'read_pcm'
  • 'OpusStreamWriter' object has no attribute 'read_bytes'

Tested with sphn 0.1.4 from PyPI.

The sphn package from PyPI (Kyutai Labs version) uses a different API than
what PersonaPlex originally expected:

- OpusStreamReader.append_bytes(bytes) -> returns np.ndarray PCM immediately
- OpusStreamWriter.append_pcm(pcm) -> returns bytes Opus data immediately

This fix updates server.py to use the correct streaming API by:
1. Buffering incoming Opus bytes in a queue
2. Processing queue items with append_bytes() and capturing returned PCM
3. Capturing Opus bytes returned from append_pcm() instead of calling read_bytes()

This resolves the AttributeError crashes on client connections:
- 'OpusStreamReader' object has no attribute 'read_pcm'
- 'OpusStreamWriter' object has no attribute 'read_bytes'

Tested with sphn 0.1.4 from PyPI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant