Skip to content

Commit 636667b

Browse files
committed
added remove silences manual test
1 parent 1517989 commit 636667b

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

playground/main.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,13 @@ const image = await composition.add(
3232
})
3333
);
3434

35-
const audioTrack = new core.AudioTrack();
36-
37-
const audioSource = await core.AudioSource.from('/silences.mp3');
38-
39-
const silences = await audioSource.silences({});
40-
41-
const audioTest = await new core.AudioClip(audioSource, {
42-
volume: 0.1,
43-
}).offsetBy(new core.Timestamp(10000));
44-
45-
await audioTrack.add(audioTest);
35+
const audioTrack = composition.createTrack('audio').stacked();
36+
await audioTrack.add(
37+
await new core.AudioClip(
38+
await core.AudioSource.from('/harvard.MP3')
39+
)
40+
);
4641
await audioTrack.removeSilences();
47-
audioTrack.stacked(true);
4842

4943
image.animate()
5044
.rotation(-16).to(14, 5).to(-7, 10).to(24, 7).to(-3, 9).to(19, 7).to(-14, 12).to(5, 9).to(-30, 13)
@@ -65,6 +59,7 @@ await composition.add(
6559

6660
(await composition.add(
6761
new core.AudioClip(await core.AudioSource.from('/audio.mp3'), {
62+
muted: true,
6863
transcript: core.Transcript.fromJSON(captions).optimize(),
6964
})
7065
)).addCaptions();

public/harvard.MP3

367 KB
Binary file not shown.

src/sources/audio.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export class AudioSource<T extends Object = {}> extends Source<T> {
8585
start = 0,
8686
stop,
8787
logarithmic = false,
88-
}: FastSamplerOptions): Promise<Float32Array> {
88+
}: FastSamplerOptions = {}): Promise<Float32Array> {
8989
if (typeof start === 'object') start = start.millis;
9090
if (typeof stop === 'object') stop = stop.millis;
9191

@@ -141,7 +141,7 @@ export class AudioSource<T extends Object = {}> extends Source<T> {
141141
threshold = -50,
142142
minDuration = 5,
143143
windowSize = 50,
144-
}: SilenceOptions): Promise<{ start: Timestamp; stop: Timestamp }[]> {
144+
}: SilenceOptions = {}): Promise<{ start: Timestamp; stop: Timestamp }[]> {
145145
if (this._silences) return this._silences;
146146

147147
const audioBuffer = this.audioBuffer ?? (await this.decode(1, DEFAULT_SAMPLE_RATE, true));

0 commit comments

Comments
 (0)