-
Notifications
You must be signed in to change notification settings - Fork 134
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
Open
Shubhrakanti
wants to merge
9
commits into
dev-1.0
Choose a base branch
from
shubhra/ajs-37-refactor-tts-with-streams
base: dev-1.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
388726d
init
Shubhrakanti f6de006
init
Shubhrakanti 20d1aeb
SyntesizeStream working
Shubhrakanti 0b64413
refactor chunk stream
Shubhrakanti 1b5d49a
bugfix
Shubhrakanti e537cc9
bugfix
Shubhrakanti 497369d
fix tests
Shubhrakanti 72816c4
nit
Shubhrakanti 89fb3e3
bugfix
Shubhrakanti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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