-
Couldn't load subscription status.
- Fork 167
Shubhra/ajs 37 refactor tts with streams #402
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
base: main
Are you sure you want to change the base?
Changes from all commits
388726d
f6de006
20d1aeb
0b64413
1b5d49a
e537cc9
497369d
72816c4
89fb3e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,21 +84,22 @@ export abstract class VAD extends (EventEmitter as new () => TypedEmitter<VADCal | |
|
|
||
| export abstract class VADStream implements AsyncIterableIterator<VADEvent> { | ||
| protected static readonly FLUSH_SENTINEL = Symbol('FLUSH_SENTINEL'); | ||
| protected input = new IdentityTransform<AudioFrame | typeof VADStream.FLUSH_SENTINEL>(); | ||
| protected output = new IdentityTransform<VADEvent>(); | ||
| protected inputWriter: WritableStreamDefaultWriter<AudioFrame | typeof VADStream.FLUSH_SENTINEL>; | ||
|
|
||
| protected inputReader: ReadableStreamDefaultReader<AudioFrame | typeof VADStream.FLUSH_SENTINEL>; | ||
| protected outputWriter: WritableStreamDefaultWriter<VADEvent>; | ||
| protected outputReader: ReadableStreamDefaultReader<VADEvent>; | ||
| protected closed = false; | ||
| protected inputClosed = false; | ||
|
|
||
| #vad: VAD; | ||
| #lastActivityTime = BigInt(0); | ||
| private logger = log(); | ||
| private deferredInputStream: DeferredReadableStream<AudioFrame>; | ||
|
|
||
| private input = new IdentityTransform<AudioFrame | typeof VADStream.FLUSH_SENTINEL>(); | ||
| private output = new IdentityTransform<VADEvent>(); | ||
| private metricsStream: ReadableStream<VADEvent>; | ||
| private outputReader: ReadableStreamDefaultReader<VADEvent>; | ||
| private inputWriter: WritableStreamDefaultWriter<AudioFrame | typeof VADStream.FLUSH_SENTINEL>; | ||
|
Comment on lines
+97
to
+101
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Making access modifiers more restrictive . Forgot to do it in #390 |
||
|
|
||
| constructor(vad: VAD) { | ||
| this.#vad = vad; | ||
| this.deferredInputStream = new DeferredReadableStream<AudioFrame>(); | ||
|
|
@@ -207,7 +208,7 @@ export abstract class VADStream implements AsyncIterableIterator<VADEvent> { | |
| throw new Error('Stream is closed'); | ||
| } | ||
| this.inputClosed = true; | ||
| this.input.writable.close(); | ||
| this.inputWriter.close(); | ||
| } | ||
|
|
||
| async next(): Promise<IteratorResult<VADEvent>> { | ||
|
|
@@ -220,7 +221,9 @@ export abstract class VADStream implements AsyncIterableIterator<VADEvent> { | |
| } | ||
|
|
||
| close() { | ||
| this.input.writable.close(); | ||
| if (!this.inputClosed) { | ||
| this.inputWriter.close(); | ||
| } | ||
|
Comment on lines
+224
to
+226
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. forgot to do in #390 |
||
| this.closed = true; | ||
| } | ||
|
|
||
|
|
||
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 is duplicative. The Readable/WritableStreamDefaultWriter internally tracks whether it's closed but doesn't expose it. The only way to know is when you try to write to or close an already-closed writer, it throws an error.
The other option would be to
everywhere, which doesn't seem much better. Let me know what you thoughts are @lukasIO @toubatbrian