-
Notifications
You must be signed in to change notification settings - Fork 171
brianyin/ajs-310-play-local-audio-file-utility #788
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
Conversation
🦋 Changeset detectedLatest commit: d2d6774 The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
agents/src/codecs/utils.ts
Outdated
| '-probesize', | ||
| '32', | ||
| '-analyzeduration', | ||
| '0', | ||
| '-fflags', | ||
| '+nobuffer+flush_packets', | ||
| '-flags', | ||
| 'low_delay', | ||
| ]) |
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 set of flags as in python
| it('should gracefully handle close while read is pending', async () => { | ||
| const channel = createStreamChannel<string>(); | ||
| const reader = channel.stream().getReader(); | ||
|
|
||
| const readPromise = reader.read(); | ||
|
|
||
| await channel.close(); | ||
|
|
||
| const result = await readPromise; | ||
| expect(result.done).toBe(true); | ||
| expect(result.value).toBeUndefined(); | ||
| }); |
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.
add tests to make sure buffered read after close still reads correct values
| for await (const frame of codecs.loopAudioFramesFromFile(audioFile, { | ||
| sampleRate: 48000, | ||
| numChannels: 1, | ||
| abortSignal: abortController.signal, | ||
| })) { | ||
| await audioSource.captureFrame(frame); | ||
| frameCount++; | ||
|
|
||
| if (frameCount % 100 === 0) { | ||
| logger.info(`Played ${frameCount} frames (${(frameCount * 0.1).toFixed(1)}s)`); | ||
| } | ||
| } | ||
| }, |
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.
example of directly playing an audio file on server side and send to livekit.
| .inputOptions([ | ||
| '-probesize', | ||
| '32', | ||
| '-analyzeduration', | ||
| '0', | ||
| '-fflags', | ||
| '+nobuffer+flush_packets', | ||
| '-flags', | ||
| 'low_delay', | ||
| ]) |
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 flags as in python
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.
when the generator closes, where do we close the ffmpeg process?
Add utility to play a local audio file.
This is a dependency of
BackgroundAudioplayer