Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions examples/cadence/models/deepfilternet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# Example script for exporting simple models to flatbuffer

import logging

from executorch.backends.cadence.aot.ops_registrations import * # noqa

import torch
from df.enhance import init_df

from executorch.backends.cadence.aot.export_example import export_model

FORMAT = "[%(levelname)s %(asctime)s %(filename)s:%(lineno)s] %(message)s"
logging.basicConfig(level=logging.INFO, format=FORMAT)


def main() -> None:
logging.info("DeepFilterNet requires pip install -q -U deepfilternet")
model, _, _= init_df()
model.eval()

spec = torch.randn(1, 1, 1061, 481, 2)
spec_feat = torch.randn(1, 1, 1061, 96, 2)
erb_feat = torch.randn(1, 1, 1061, 32)

example_inputs = (
spec,
erb_feat,
spec_feat,
)

export_model(model, example_inputs)


if __name__ == "__main__":
main()
36 changes: 36 additions & 0 deletions examples/cadence/models/encodec.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# Example script for exporting simple models to flatbuffer

import logging

from executorch.backends.cadence.aot.ops_registrations import * # noqa

import torch
from encodec import EncodecModel

from executorch.backends.cadence.aot.export_example import export_model

FORMAT = "[%(levelname)s %(asctime)s %(filename)s:%(lineno)s] %(message)s"
logging.basicConfig(level=logging.INFO, format=FORMAT)


def main() -> None:
logging.info("Encodec requires pip install -U encodec")
model = EncodecModel.encodec_model_24khz()
model.set_target_bandwidth(6.0)
model.eval()

wav = torch.randn(1, 1, 144000)

example_inputs = (wav,)

export_model(model, example_inputs)


if __name__ == "__main__":
main()
44 changes: 44 additions & 0 deletions examples/cadence/models/tacotron2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# Example script for exporting simple models to flatbuffer

import logging

from executorch.backends.cadence.aot.ops_registrations import * # noqa

import torchaudio

from executorch.backends.cadence.aot.export_example import export_model

FORMAT = "[%(levelname)s %(asctime)s %(filename)s:%(lineno)s] %(message)s"
logging.basicConfig(level=logging.INFO, format=FORMAT)


def main() -> None:
text = "Hello world! T T S stands for Text to Speech!"

bundle = torchaudio.pipelines.TACOTRON2_WAVERNN_CHAR_LJSPEECH
processor = bundle.get_text_processor()
model = bundle.get_tacotron2()
model.eval()

tokens, tokens_length = processor(text)
specgram, specgram_lengths, _ = model.infer(tokens, tokens_length)

inputs = (
tokens,
tokens_length,
specgram,
specgram_lengths,
)

# Full model
export_model(model, inputs)


if __name__ == "__main__":
main()
Loading