Skip to content

Commit

Permalink
Support text-to-waveform with preprocessor
Browse files Browse the repository at this point in the history
  • Loading branch information
hans00 committed Jun 17, 2024
1 parent 4be6c3e commit 5112824
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/pipelines.js
Original file line number Diff line number Diff line change
Expand Up @@ -2643,8 +2643,7 @@ export class TextToAudioPipeline extends (/** @type {new (options: TextToAudioPi
speaker_embeddings = null,
} = {}) {

// If this.processor is not set, we are using a `AutoModelForTextToWaveform` model
if (this.processor) {
if (AutoModelForTextToSpectrogram.MODEL_CLASS_MAPPINGS[0].has(this.model.config.model_type)) {
return this._call_text_to_spectrogram(text_inputs, { speaker_embeddings });
} else {
return this._call_text_to_waveform(text_inputs);
Expand All @@ -2653,11 +2652,15 @@ export class TextToAudioPipeline extends (/** @type {new (options: TextToAudioPi

async _call_text_to_waveform(text_inputs) {

// Run tokenization
const inputs = this.tokenizer(text_inputs, {
padding: true,
truncation: true,
});
let inputs;
if (this.processor) {
inputs = this.processor(text_inputs);
} else {
inputs = this.tokenizer(text_inputs, {
padding: true,
truncation: true,
});
}

// Generate waveform
const { waveform } = await this.model(inputs);
Expand Down

0 comments on commit 5112824

Please sign in to comment.