diff --git a/.github/actions/lyra-builder/action.yml b/.github/actions/lyra-builder/action.yml index 7d9ca6f4..fb14b3f7 100644 --- a/.github/actions/lyra-builder/action.yml +++ b/.github/actions/lyra-builder/action.yml @@ -20,17 +20,17 @@ runs: - shell: bash run: | export ANDROID_NDK_HOME="$ANDROID_HOME/ndk/21.4.7075529" - bazel build -c opt :encoder_main ${{ inputs.build-options }} + bazel build -c opt lyra/cli_example:encoder_main ${{ inputs.build-options }} - shell: bash run: | export ANDROID_NDK_HOME="$ANDROID_HOME/ndk/21.4.7075529" - bazel build -c opt :decoder_main ${{ inputs.build-options }} + bazel build -c opt lyra/cli_example:decoder_main ${{ inputs.build-options }} - shell: bash run: | mkdir action-product - cp -r model_coeffs action-product/ - cp bazel-bin/encoder_main action-product/lyra-encoder - cp bazel-bin/decoder_main action-product/lyra-decoder + cp -r lyra/model_coeffs action-product/ + cp bazel-bin/lyra/cli_example/encoder_main action-product/lyra-encoder + cp bazel-bin/lyra/cli_example/decoder_main action-product/lyra-decoder - uses: actions/upload-artifact@v2 with: name: lyra-${{ inputs.platform }}-${{ inputs.architecture }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b9abadd..5bda4026 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,12 +18,12 @@ jobs: shell: bash run: | export ANDROID_NDK_HOME="$ANDROID_HOME/ndk/21.4.7075529" - bazel build android_example:lyra_android_example --config=android_arm64 --copt=-DBENCHMARK + bazel build lyra/android_example:lyra_android_example --config=android_arm64 --copt=-DBENCHMARK - name: Copy artifacts shell: bash run: | mkdir action-product - cp bazel-bin/android_example/lyra_android_example.apk action-product/lyra_example.apk + cp bazel-bin/lyra/android_example/lyra_android_example.apk action-product/lyra_example.apk - name: Upload artifact uses: actions/upload-artifact@v2 with: diff --git a/BUILD b/BUILD index 5dc8c30e..0c1469ee 100644 --- a/BUILD +++ b/BUILD @@ -1,1003 +1,5 @@ -# [internal] load cc_fuzz_target.bzl -# [internal] load cc_proto_library.bzl -# [internal] load android_cc_test:def.bzl - package(default_visibility = [":__subpackages__"]) licenses(["notice"]) -# To run all cc_tests in this directory: -# bazel test //:all - -# [internal] Command to run dsp_utils_android_test. - -# [internal] Command to run lyra_integration_android_test. - exports_files(["LICENSE"]) - -exports_files( - srcs = [ - "decoder_main.cc", - "decoder_main_lib.cc", - "decoder_main_lib.h", - "encoder_main.cc", - "encoder_main_lib.cc", - "encoder_main_lib.h", - "lyra_benchmark.cc", - "lyra_benchmark_lib.cc", - "lyra_benchmark_lib.h", - "lyra_components.h", - "lyra_config.h", - "lyra_decoder.cc", - "lyra_decoder.h", - "lyra_encoder.cc", - "lyra_encoder.h", - "model_coeffs/lyragan.tflite", - "model_coeffs/quantizer.tflite", - "model_coeffs/soundstream_encoder.tflite", - ], -) - -config_setting( - name = "android_config", - values = {"crosstool_top": "//external:android/crosstool"}, -) - -cc_library( - name = "architecture_utils", - hdrs = ["architecture_utils.h"], - deps = ["@gulrak_filesystem//:filesystem"], -) - -cc_library( - name = "lyra_benchmark_lib", - srcs = ["lyra_benchmark_lib.cc"], - hdrs = ["lyra_benchmark_lib.h"], - deps = [ - ":architecture_utils", - ":dsp_utils", - ":feature_extractor_interface", - ":generative_model_interface", - ":lyra_components", - ":lyra_config", - "@com_google_absl//absl/base:core_headers", - "@com_google_absl//absl/strings", - "@com_google_absl//absl/strings:str_format", - "@com_google_absl//absl/time", - "@com_google_absl//absl/types:span", - "@com_google_audio_dsp//audio/dsp:signal_vector_util", - "@com_google_glog//:glog", - "@gulrak_filesystem//:filesystem", - ], -) - -cc_library( - name = "feature_estimator_interface", - hdrs = [ - "feature_estimator_interface.h", - ], - deps = [ - "@com_google_absl//absl/types:span", - ], -) - -cc_library( - name = "zero_feature_estimator", - hdrs = [ - "zero_feature_estimator.h", - ], - deps = [ - ":feature_estimator_interface", - "@com_google_absl//absl/types:span", - ], -) - -cc_library( - name = "generative_model_interface", - hdrs = [ - "generative_model_interface.h", - ], - deps = [ - "@com_google_glog//:glog", - ], -) - -cc_library( - name = "resampler_interface", - hdrs = [ - "resampler_interface.h", - ], - deps = [ - "@com_google_absl//absl/types:span", - ], -) - -cc_library( - name = "feature_extractor_interface", - hdrs = [ - "feature_extractor_interface.h", - ], - deps = [ - "@com_google_absl//absl/types:span", - ], -) - -cc_library( - name = "lyra_decoder_interface", - hdrs = [ - "lyra_decoder_interface.h", - ], - deps = [ - "@com_google_absl//absl/types:span", - ], -) - -cc_library( - name = "lyra_encoder_interface", - hdrs = [ - "lyra_encoder_interface.h", - ], - deps = [ - "@com_google_absl//absl/types:span", - ], -) - -cc_library( - name = "vector_quantizer_interface", - hdrs = [ - "vector_quantizer_interface.h", - ], - deps = [ - ], -) - -cc_library( - name = "lyra_gan_model", - srcs = [ - "lyra_gan_model.cc", - ], - hdrs = [ - "lyra_gan_model.h", - ], - data = ["model_coeffs/lyragan.tflite"], - deps = [ - ":dsp_utils", - ":generative_model_interface", - ":tflite_model_wrapper", - "@com_google_absl//absl/memory", - "@com_google_absl//absl/types:span", - "@com_google_glog//:glog", - "@gulrak_filesystem//:filesystem", - ], -) - -cc_library( - name = "lyra_decoder", - srcs = [ - "lyra_decoder.cc", - ], - hdrs = [ - "lyra_decoder.h", - ], - visibility = ["//visibility:public"], - deps = [ - ":buffered_filter_interface", - ":buffered_resampler", - ":comfort_noise_generator", - ":feature_estimator_interface", - ":generative_model_interface", - ":lyra_components", - ":lyra_config", - ":lyra_decoder_interface", - ":noise_estimator", - ":noise_estimator_interface", - ":vector_quantizer_interface", - "@com_google_absl//absl/memory", - "@com_google_absl//absl/status", - "@com_google_absl//absl/types:span", - "@com_google_glog//:glog", - "@gulrak_filesystem//:filesystem", - ], -) - -cc_library( - name = "decoder_main_lib", - srcs = [ - "decoder_main_lib.cc", - ], - hdrs = [ - "decoder_main_lib.h", - ], - deps = [ - ":fixed_packet_loss_model", - ":gilbert_model", - ":lyra_config", - ":lyra_decoder", - ":packet_loss_model_interface", - ":wav_utils", - "@com_google_absl//absl/flags:marshalling", - "@com_google_absl//absl/random", - "@com_google_absl//absl/random:bit_gen_ref", - "@com_google_absl//absl/status", - "@com_google_absl//absl/strings", - "@com_google_absl//absl/time", - "@com_google_absl//absl/types:span", - "@com_google_glog//:glog", - "@gulrak_filesystem//:filesystem", - ], -) - -cc_library( - name = "comfort_noise_generator", - srcs = [ - "comfort_noise_generator.cc", - ], - hdrs = [ - "comfort_noise_generator.h", - ], - deps = [ - ":dsp_utils", - ":generative_model_interface", - ":log_mel_spectrogram_extractor_impl", - "@com_google_absl//absl/memory", - "@com_google_absl//absl/random", - "@com_google_absl//absl/types:span", - "@com_google_audio_dsp//audio/dsp:number_util", - "@com_google_audio_dsp//audio/dsp/mfcc", - "@com_google_audio_dsp//audio/dsp/spectrogram:inverse_spectrogram", - "@com_google_glog//:glog", - ], -) - -cc_library( - name = "lyra_encoder", - srcs = [ - "lyra_encoder.cc", - ], - hdrs = [ - "lyra_encoder.h", - ], - visibility = ["//visibility:public"], - deps = [ - ":feature_extractor_interface", - ":lyra_components", - ":lyra_config", - ":lyra_encoder_interface", - ":noise_estimator", - ":noise_estimator_interface", - ":packet", - ":packet_interface", - ":resampler", - ":resampler_interface", - ":vector_quantizer_interface", - "@com_google_absl//absl/memory", - "@com_google_absl//absl/status", - "@com_google_absl//absl/types:span", - "@com_google_glog//:glog", - "@gulrak_filesystem//:filesystem", - ], -) - -cc_library( - name = "encoder_main_lib", - srcs = [ - "encoder_main_lib.cc", - ], - hdrs = [ - "encoder_main_lib.h", - ], - deps = [ - ":lyra_config", - ":lyra_encoder", - ":no_op_preprocessor", - ":wav_utils", - "@com_google_absl//absl/status", - "@com_google_absl//absl/status:statusor", - "@com_google_absl//absl/strings", - "@com_google_absl//absl/time", - "@com_google_absl//absl/types:span", - "@com_google_glog//:glog", - "@gulrak_filesystem//:filesystem", - ], -) - -cc_library( - name = "noise_estimator", - srcs = [ - "noise_estimator.cc", - ], - hdrs = [ - "noise_estimator.h", - ], - deps = [ - ":log_mel_spectrogram_extractor_impl", - ":noise_estimator_interface", - "@com_google_absl//absl/memory", - "@com_google_absl//absl/types:span", - "@com_google_audio_dsp//audio/dsp:signal_vector_util", - "@com_google_glog//:glog", - ], -) - -cc_library( - name = "noise_estimator_interface", - hdrs = [ - "noise_estimator_interface.h", - ], - deps = [ - "@com_google_absl//absl/types:span", - ], -) - -cc_library( - name = "packet_loss_model_interface", - hdrs = ["packet_loss_model_interface.h"], - deps = [], -) - -cc_library( - name = "fixed_packet_loss_model", - srcs = [ - "fixed_packet_loss_model.cc", - ], - hdrs = [ - "fixed_packet_loss_model.h", - ], - deps = [":packet_loss_model_interface"], -) - -cc_library( - name = "gilbert_model", - srcs = [ - "gilbert_model.cc", - ], - hdrs = [ - "gilbert_model.h", - ], - deps = [ - ":packet_loss_model_interface", - "@com_google_absl//absl/memory", - "@com_google_glog//:glog", - ], -) - -cc_library( - name = "lyra_config", - srcs = ["lyra_config.cc"], - hdrs = ["lyra_config.h"], - deps = [ - ":lyra_config_cc_proto", - "@com_google_absl//absl/base:core_headers", - "@com_google_absl//absl/status", - "@com_google_absl//absl/strings", - "@com_google_absl//absl/strings:str_format", - "@com_google_glog//:glog", - "@gulrak_filesystem//:filesystem", - ], -) - -proto_library( - name = "lyra_config_proto", - srcs = ["lyra_config.proto"], -) - -cc_proto_library( - name = "lyra_config_cc_proto", - deps = [":lyra_config_proto"], -) - -cc_library( - name = "lyra_components", - srcs = [ - "lyra_components.cc", - ], - hdrs = [ - "lyra_components.h", - ], - deps = [ - ":feature_estimator_interface", - ":feature_extractor_interface", - ":generative_model_interface", - ":lyra_gan_model", - ":packet", - ":packet_interface", - ":residual_vector_quantizer", - ":soundstream_encoder", - ":vector_quantizer_interface", - ":zero_feature_estimator", - "@gulrak_filesystem//:filesystem", - ], -) - -cc_library( - name = "log_mel_spectrogram_extractor_impl", - srcs = [ - "log_mel_spectrogram_extractor_impl.cc", - ], - hdrs = [ - "log_mel_spectrogram_extractor_impl.h", - ], - deps = [ - ":feature_extractor_interface", - "@com_google_absl//absl/memory", - "@com_google_absl//absl/types:span", - "@com_google_audio_dsp//audio/dsp:number_util", - "@com_google_audio_dsp//audio/dsp/mfcc", - "@com_google_audio_dsp//audio/dsp/spectrogram", - "@com_google_glog//:glog", - ], -) - -cc_library( - name = "soundstream_encoder", - srcs = [ - "soundstream_encoder.cc", - ], - hdrs = [ - "soundstream_encoder.h", - ], - data = ["model_coeffs/soundstream_encoder.tflite"], - deps = [ - ":dsp_utils", - ":feature_extractor_interface", - ":tflite_model_wrapper", - "@com_google_absl//absl/memory", - "@com_google_absl//absl/types:span", - "@com_google_glog//:glog", - "@gulrak_filesystem//:filesystem", - ], -) - -cc_library( - name = "residual_vector_quantizer", - srcs = [ - "residual_vector_quantizer.cc", - ], - hdrs = [ - "residual_vector_quantizer.h", - ], - data = [ - "model_coeffs/quantizer.tflite", - ], - deps = [ - ":tflite_model_wrapper", - ":vector_quantizer_interface", - "@com_google_absl//absl/memory", - "@com_google_glog//:glog", - "@gulrak_filesystem//:filesystem", - ], -) - -cc_library( - name = "packet_interface", - hdrs = [ - "packet_interface.h", - ], - deps = [ - "@com_google_absl//absl/types:span", - ], -) - -cc_library( - name = "packet", - hdrs = ["packet.h"], - deps = [ - ":packet_interface", - "@com_google_absl//absl/memory", - "@com_google_absl//absl/types:span", - "@com_google_glog//:glog", - ], -) - -cc_library( - name = "buffered_filter_interface", - hdrs = ["buffered_filter_interface.h"], -) - -cc_library( - name = "buffered_resampler", - srcs = ["buffered_resampler.cc"], - hdrs = ["buffered_resampler.h"], - deps = [ - ":buffered_filter_interface", - ":resampler", - ":resampler_interface", - "@com_google_absl//absl/memory", - "@com_google_glog//:glog", - ], -) - -cc_test( - name = "buffered_resampler_test", - srcs = ["buffered_resampler_test.cc"], - deps = [ - ":buffered_resampler", - ":lyra_config", - ":resampler_interface", - "//testing:mock_resampler", - "@com_google_absl//absl/types:span", - "@com_google_googletest//:gtest_main", - ], -) - -cc_library( - name = "preprocessor_interface", - hdrs = [ - "preprocessor_interface.h", - ], - deps = [ - "@com_google_absl//absl/types:span", - ], -) - -cc_library( - name = "no_op_preprocessor", - hdrs = [ - "no_op_preprocessor.h", - ], - deps = [ - ":preprocessor_interface", - "@com_google_absl//absl/types:span", - ], -) - -cc_test( - name = "no_op_preprocessor_test", - size = "small", - srcs = ["no_op_preprocessor_test.cc"], - deps = [ - ":no_op_preprocessor", - "@com_google_absl//absl/types:span", - "@com_google_googletest//:gtest_main", - ], -) - -cc_binary( - name = "encoder_main", - srcs = [ - "encoder_main.cc", - ], - data = [":tflite_testdata"], - linkopts = select({ - ":android_config": ["-landroid"], - "//conditions:default": [], - }), - deps = [ - ":architecture_utils", - ":encoder_main_lib", - "@com_google_absl//absl/flags:flag", - "@com_google_absl//absl/flags:parse", - "@com_google_absl//absl/flags:usage", - "@com_google_absl//absl/strings", - "@com_google_glog//:glog", - "@gulrak_filesystem//:filesystem", - ], -) - -cc_binary( - name = "decoder_main", - srcs = [ - "decoder_main.cc", - ], - data = [":tflite_testdata"], - linkopts = select({ - ":android_config": ["-landroid"], - "//conditions:default": [], - }), - deps = [ - ":architecture_utils", - ":decoder_main_lib", - "@com_google_absl//absl/flags:flag", - "@com_google_absl//absl/flags:parse", - "@com_google_absl//absl/flags:usage", - "@com_google_absl//absl/strings", - "@com_google_glog//:glog", - "@gulrak_filesystem//:filesystem", - ], -) - -cc_binary( - name = "lyra_benchmark", - srcs = [ - "lyra_benchmark.cc", - ], - linkopts = select({ - ":android_config": ["-landroid"], - "//conditions:default": [], - }), - deps = [ - ":lyra_benchmark_lib", - "@com_google_absl//absl/flags:flag", - "@com_google_absl//absl/flags:parse", - "@com_google_absl//absl/flags:usage", - "@com_google_absl//absl/strings", - ], -) - -cc_test( - name = "lyra_decoder_test", - size = "large", - srcs = ["lyra_decoder_test.cc"], - data = [":tflite_testdata"], - shard_count = 8, - deps = [ - ":buffered_filter_interface", - ":buffered_resampler", - ":dsp_utils", - ":feature_estimator_interface", - ":generative_model_interface", - ":lyra_components", - ":lyra_config", - ":lyra_decoder", - ":packet_interface", - ":resampler", - ":vector_quantizer_interface", - "//testing:mock_generative_model", - "//testing:mock_noise_estimator", - "//testing:mock_vector_quantizer", - "@com_google_absl//absl/strings", - "@com_google_absl//absl/types:span", - "@com_google_googletest//:gtest_main", - "@gulrak_filesystem//:filesystem", - ], -) - -cc_test( - name = "comfort_noise_generator_test", - size = "small", - srcs = ["comfort_noise_generator_test.cc"], - deps = [ - ":comfort_noise_generator", - ":dsp_utils", - ":log_mel_spectrogram_extractor_impl", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "lyra_gan_model_test", - srcs = ["lyra_gan_model_test.cc"], - deps = [ - ":lyra_config", - ":lyra_gan_model", - "@com_google_googletest//:gtest_main", - "@gulrak_filesystem//:filesystem", - ], -) - -cc_test( - name = "lyra_integration_test", - size = "small", - timeout = "long", - srcs = ["lyra_integration_test.cc"], - data = [ - ":tflite_testdata", - "//testdata:sample1_16kHz.wav", - "//testdata:sample1_32kHz.wav", - "//testdata:sample1_48kHz.wav", - "//testdata:sample1_8kHz.wav", - ], - shard_count = 4, - deps = [ - ":dsp_utils", - ":log_mel_spectrogram_extractor_impl", - ":lyra_config", - ":lyra_decoder", - ":lyra_encoder", - ":wav_utils", - "@com_google_absl//absl/status:statusor", - "@com_google_absl//absl/strings", - "@com_google_absl//absl/types:span", - "@com_google_googletest//:gtest_main", - "@gulrak_filesystem//:filesystem", - ], -) - -cc_test( - name = "encoder_main_lib_test", - size = "small", - srcs = ["encoder_main_lib_test.cc"], - data = [ - ":tflite_testdata", - "//testdata:sample1_16kHz.wav", - "//testdata:sample1_32kHz.wav", - "//testdata:sample1_48kHz.wav", - "//testdata:sample1_8kHz.wav", - ], - deps = [ - ":encoder_main_lib", - "@com_google_absl//absl/flags:flag", - "@com_google_absl//absl/strings", - "@com_google_googletest//:gtest_main", - "@gulrak_filesystem//:filesystem", - ], -) - -cc_test( - name = "decoder_main_lib_test", - size = "large", - srcs = ["decoder_main_lib_test.cc"], - data = [ - ":tflite_testdata", - "//testdata:incomplete_encoded_packet.lyra", - "//testdata:no_encoded_packet.lyra", - "//testdata:one_encoded_packet_16khz.lyra", - "//testdata:two_encoded_packets_16khz.lyra", - ], - shard_count = 4, - deps = [ - ":decoder_main_lib", - ":lyra_config", - ":wav_utils", - "@com_google_absl//absl/flags:flag", - "@com_google_absl//absl/status:statusor", - "@com_google_absl//absl/strings", - "@com_google_googletest//:gtest_main", - "@gulrak_filesystem//:filesystem", - ], -) - -cc_test( - name = "noise_estimator_test", - size = "small", - srcs = ["noise_estimator_test.cc"], - deps = [ - ":comfort_noise_generator", - ":dsp_utils", - ":log_mel_spectrogram_extractor_impl", - ":lyra_config", - ":noise_estimator", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "fixed_packet_loss_model_test", - size = "small", - srcs = ["fixed_packet_loss_model_test.cc"], - deps = [ - ":fixed_packet_loss_model", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "gilbert_model_test", - size = "small", - srcs = ["gilbert_model_test.cc"], - deps = [ - ":gilbert_model", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "log_mel_spectrogram_extractor_impl_test", - size = "small", - srcs = ["log_mel_spectrogram_extractor_impl_test.cc"], - deps = [ - ":log_mel_spectrogram_extractor_impl", - "@com_google_absl//absl/types:span", - "@com_google_googletest//:gtest_main", - ], -) - -cc_binary( - name = "log_mel_spectrogram_extractor_impl_benchmark", - testonly = 1, - srcs = ["log_mel_spectrogram_extractor_impl_benchmark.cc"], - deps = [ - ":log_mel_spectrogram_extractor_impl", - "@com_github_google_benchmark//:benchmark", - "@com_github_google_benchmark//:benchmark_main", - "@com_google_absl//absl/random", - "@com_google_absl//absl/types:span", - ], -) - -cc_test( - name = "soundstream_encoder_test", - srcs = ["soundstream_encoder_test.cc"], - deps = [ - ":lyra_config", - ":soundstream_encoder", - "@com_google_googletest//:gtest_main", - "@gulrak_filesystem//:filesystem", - ], -) - -cc_test( - name = "lyra_encoder_test", - size = "small", - srcs = ["lyra_encoder_test.cc"], - data = [":tflite_testdata"], - shard_count = 8, - deps = [ - ":feature_extractor_interface", - ":lyra_config", - ":lyra_encoder", - ":noise_estimator_interface", - ":packet", - ":resampler_interface", - ":vector_quantizer_interface", - "//testing:mock_feature_extractor", - "//testing:mock_noise_estimator", - "//testing:mock_resampler", - "//testing:mock_vector_quantizer", - "@com_google_absl//absl/types:span", - "@com_google_googletest//:gtest_main", - "@gulrak_filesystem//:filesystem", - ], -) - -cc_test( - name = "residual_vector_quantizer_test", - size = "small", - srcs = [ - "residual_vector_quantizer_test.cc", - ], - deps = [ - ":log_mel_spectrogram_extractor_impl", - ":lyra_config", - ":residual_vector_quantizer", - "@com_google_googletest//:gtest_main", - "@gulrak_filesystem//:filesystem", - ], -) - -cc_test( - name = "packet_test", - size = "small", - srcs = ["packet_test.cc"], - deps = [ - ":packet", - "@com_google_absl//absl/types:span", - "@com_google_googletest//:gtest_main", - ], -) - -cc_library( - name = "resampler", - srcs = [ - "resampler.cc", - ], - hdrs = ["resampler.h"], - deps = [ - ":dsp_utils", - ":resampler_interface", - "@com_google_absl//absl/memory", - "@com_google_absl//absl/types:span", - "@com_google_audio_dsp//audio/dsp:resampler_q", - "@com_google_glog//:glog", - ], -) - -cc_test( - name = "resampler_test", - size = "small", - srcs = ["resampler_test.cc"], - deps = [ - ":lyra_config", - ":resampler", - "@com_google_absl//absl/types:span", - "@com_google_audio_dsp//audio/dsp:signal_vector_util", - "@com_google_googletest//:gtest_main", - ], -) - -cc_library( - name = "dsp_utils", - srcs = [ - "dsp_utils.cc", - ], - hdrs = ["dsp_utils.h"], - deps = [ - "@com_google_absl//absl/types:span", - "@com_google_audio_dsp//audio/dsp:signal_vector_util", - "@com_google_glog//:glog", - ], -) - -cc_library( - name = "wav_utils", - srcs = [ - "wav_utils.cc", - ], - hdrs = ["wav_utils.h"], - deps = [ - "@com_google_absl//absl/status", - "@com_google_absl//absl/status:statusor", - "@com_google_absl//absl/strings", - "@com_google_audio_dsp//audio/dsp/portable:read_wav_file", - "@com_google_audio_dsp//audio/dsp/portable:write_wav_file", - ], -) - -cc_library( - name = "tflite_model_wrapper", - srcs = [ - "tflite_model_wrapper.cc", - ], - hdrs = [ - "tflite_model_wrapper.h", - ], - deps = [ - "@com_google_absl//absl/memory", - "@com_google_absl//absl/types:span", - "@com_google_glog//:glog", - "@gulrak_filesystem//:filesystem", - "@org_tensorflow//tensorflow/lite:framework", - "@org_tensorflow//tensorflow/lite/delegates/xnnpack:xnnpack_delegate", - "@org_tensorflow//tensorflow/lite/kernels:builtin_ops", - ], -) - -cc_test( - name = "wav_utils_test", - size = "small", - srcs = ["wav_utils_test.cc"], - data = [ - "//testdata:invalid.wav", - "//testdata:sample1_16kHz.wav", - ], - deps = [ - ":wav_utils", - "@com_google_absl//absl/flags:flag", - "@com_google_absl//absl/status", - "@com_google_absl//absl/status:statusor", - "@com_google_googletest//:gtest_main", - "@gulrak_filesystem//:filesystem", - ], -) - -cc_test( - name = "dsp_utils_test", - size = "small", - srcs = ["dsp_utils_test.cc"], - deps = [ - ":dsp_utils", - "@com_google_absl//absl/types:span", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "tflite_model_wrapper_test", - srcs = ["tflite_model_wrapper_test.cc"], - data = ["model_coeffs/lyragan.tflite"], - deps = [ - ":tflite_model_wrapper", - "@com_google_absl//absl/types:span", - "@com_google_googletest//:gtest_main", - "@gulrak_filesystem//:filesystem", - "@org_tensorflow//tensorflow/lite:framework", - ], -) - -cc_test( - name = "lyra_config_test", - srcs = ["lyra_config_test.cc"], - data = [":tflite_testdata"], - deps = [ - ":lyra_config", - ":lyra_config_cc_proto", - "@com_google_absl//absl/flags:flag", - "@com_google_absl//absl/status", - "@com_google_googletest//:gtest_main", - "@gulrak_filesystem//:filesystem", - ], -) - -filegroup( - name = "tflite_testdata", - data = glob([ - "model_coeffs/*", - ]), -) - -filegroup( - name = "android_example_assets", - srcs = glob([ - "model_coeffs/*.tflite", - ]) + ["model_coeffs/lyra_config.binarypb"], -) diff --git a/README.md b/README.md index bfb0dc5a..c3b534db 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ You can build the cc_binaries with the default config. `encoder_main` is an example of a file encoder. ```shell -bazel build -c opt :encoder_main +bazel build -c opt lyra/cli_example:encoder_main ``` You can run `encoder_main` to encode a test .wav file with some speech in it, @@ -107,15 +107,15 @@ encoded (compressed) representation, and the desired bitrate can be specified using the `--bitrate` flag. ```shell -bazel-bin/encoder_main --input_path=testdata/sample1_16kHz.wav --output_dir=$HOME/temp --bitrate=3200 +bazel-bin/lyra/cli_example/encoder_main --input_path=lyra/testdata/sample1_16kHz.wav --output_dir=$HOME/temp --bitrate=3200 ``` Similarly, you can build decoder_main and use it on the output of encoder_main to decode the encoded data back into speech. ```shell -bazel build -c opt :decoder_main -bazel-bin/decoder_main --encoded_path=$HOME/temp/sample1_16kHz.lyra --output_dir=$HOME/temp/ --bitrate=3200 +bazel build -c opt lyra/cli_example:decoder_main +bazel-bin/lyra/cli_example/decoder_main --encoded_path=$HOME/temp/sample1_16kHz.lyra --output_dir=$HOME/temp/ --bitrate=3200 ``` Note: the default Bazel toolchain is automatically configured and likely uses @@ -137,8 +137,8 @@ benchmark that encodes and decodes in the background and prints the timings to logcat. ```shell -bazel build -c opt android_example:lyra_android_example --config=android_arm64 --copt=-DBENCHMARK -adb install bazel-bin/android_example/lyra_android_example.apk +bazel build -c opt lyra/android_example:lyra_android_example --config=android_arm64 --copt=-DBENCHMARK +adb install bazel-bin/lyra/android_example/lyra_android_example.apk ``` After this you should see an app called "Lyra Example App". @@ -182,8 +182,8 @@ and decoding .wav files. You can build the example cc_binary targets with: ```shell -bazel build -c opt :encoder_main --config=android_arm64 -bazel build -c opt :decoder_main --config=android_arm64 +bazel build -c opt lyra/cli_example:encoder_main --config=android_arm64 +bazel build -c opt lyra/cli_example:decoder_main --config=android_arm64 ``` This builds an executable binary that can be run on android 64-bit arm devices @@ -192,10 +192,10 @@ a binary through the shell. ```shell # Push the binary and the data it needs, including the model and .wav files: -adb push bazel-bin/encoder_main /data/local/tmp/ -adb push bazel-bin/decoder_main /data/local/tmp/ -adb push model_coeffs/ /data/local/tmp/ -adb push testdata/ /data/local/tmp/ +adb push bazel-bin/lyra/cli_example/encoder_main /data/local/tmp/ +adb push bazel-bin/lyra/cli_example/decoder_main /data/local/tmp/ +adb push lyra/model_coeffs/ /data/local/tmp/ +adb push lyra/testdata/ /data/local/tmp/ adb shell cd /data/local/tmp @@ -230,7 +230,7 @@ section once this is completed. ## API For integrating Lyra into any project only two APIs are relevant: -[LyraEncoder](lyra_encoder.h) and [LyraDecoder](lyra_decoder.h). +[LyraEncoder](lyra/lyra_encoder.h) and [LyraDecoder](lyra/lyra_decoder.h). > DISCLAIMER: At this time Lyra's API and bit-stream are **not** guaranteed to > be stable and might change in future versions of the code. @@ -324,7 +324,7 @@ predetermined parameters. For an example on how to use `LyraEncoder` and `LyraDecoder` to encode and decode a stream of audio, please refer to the -[integration test](lyra_integration_test.cc). +[integration test](lyra/lyra_integration_test.cc). ## License diff --git a/lyra/BUILD b/lyra/BUILD new file mode 100644 index 00000000..a64673ce --- /dev/null +++ b/lyra/BUILD @@ -0,0 +1,854 @@ +# [internal] load cc_fuzz_target.bzl +# [internal] load cc_proto_library.bzl +# [internal] load android_cc_test:def.bzl + +package(default_visibility = ["//:__subpackages__"]) + +# To run all cc_tests in this directory: +# bazel test //lyra:all + +# [internal] Command to run dsp_utils_android_test. + +# [internal] Command to run lyra_integration_android_test. + +exports_files( + srcs = [ + "lyra_benchmark_lib.cc", + "lyra_benchmark_lib.h", + "lyra_components.h", + "lyra_config.h", + "lyra_decoder.cc", + "lyra_decoder.h", + "lyra_encoder.cc", + "lyra_encoder.h", + "model_coeffs/lyragan.tflite", + "model_coeffs/quantizer.tflite", + "model_coeffs/soundstream_encoder.tflite", + ], +) + +config_setting( + name = "android_config", + values = {"crosstool_top": "//external:android/crosstool"}, +) + +cc_library( + name = "architecture_utils", + hdrs = ["architecture_utils.h"], + deps = ["@gulrak_filesystem//:filesystem"], +) + +cc_library( + name = "lyra_benchmark_lib", + srcs = ["lyra_benchmark_lib.cc"], + hdrs = ["lyra_benchmark_lib.h"], + deps = [ + ":architecture_utils", + ":dsp_utils", + ":feature_extractor_interface", + ":generative_model_interface", + ":lyra_components", + ":lyra_config", + "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/strings", + "@com_google_absl//absl/strings:str_format", + "@com_google_absl//absl/time", + "@com_google_absl//absl/types:span", + "@com_google_audio_dsp//audio/dsp:signal_vector_util", + "@com_google_glog//:glog", + "@gulrak_filesystem//:filesystem", + ], +) + +cc_library( + name = "feature_estimator_interface", + hdrs = [ + "feature_estimator_interface.h", + ], + deps = [ + "@com_google_absl//absl/types:span", + ], +) + +cc_library( + name = "zero_feature_estimator", + hdrs = [ + "zero_feature_estimator.h", + ], + deps = [ + ":feature_estimator_interface", + "@com_google_absl//absl/types:span", + ], +) + +cc_library( + name = "generative_model_interface", + hdrs = [ + "generative_model_interface.h", + ], + deps = [ + "@com_google_glog//:glog", + ], +) + +cc_library( + name = "resampler_interface", + hdrs = [ + "resampler_interface.h", + ], + deps = [ + "@com_google_absl//absl/types:span", + ], +) + +cc_library( + name = "feature_extractor_interface", + hdrs = [ + "feature_extractor_interface.h", + ], + deps = [ + "@com_google_absl//absl/types:span", + ], +) + +cc_library( + name = "lyra_decoder_interface", + hdrs = [ + "lyra_decoder_interface.h", + ], + deps = [ + "@com_google_absl//absl/types:span", + ], +) + +cc_library( + name = "lyra_encoder_interface", + hdrs = [ + "lyra_encoder_interface.h", + ], + deps = [ + "@com_google_absl//absl/types:span", + ], +) + +cc_library( + name = "vector_quantizer_interface", + hdrs = [ + "vector_quantizer_interface.h", + ], + deps = [ + ], +) + +cc_library( + name = "lyra_gan_model", + srcs = [ + "lyra_gan_model.cc", + ], + hdrs = [ + "lyra_gan_model.h", + ], + data = ["model_coeffs/lyragan.tflite"], + deps = [ + ":dsp_utils", + ":generative_model_interface", + ":tflite_model_wrapper", + "@com_google_absl//absl/memory", + "@com_google_absl//absl/types:span", + "@com_google_glog//:glog", + "@gulrak_filesystem//:filesystem", + ], +) + +cc_library( + name = "lyra_decoder", + srcs = [ + "lyra_decoder.cc", + ], + hdrs = [ + "lyra_decoder.h", + ], + visibility = ["//visibility:public"], + deps = [ + ":buffered_filter_interface", + ":buffered_resampler", + ":comfort_noise_generator", + ":feature_estimator_interface", + ":generative_model_interface", + ":lyra_components", + ":lyra_config", + ":lyra_decoder_interface", + ":noise_estimator", + ":noise_estimator_interface", + ":vector_quantizer_interface", + "@com_google_absl//absl/memory", + "@com_google_absl//absl/status", + "@com_google_absl//absl/types:span", + "@com_google_glog//:glog", + "@gulrak_filesystem//:filesystem", + ], +) + +cc_library( + name = "comfort_noise_generator", + srcs = [ + "comfort_noise_generator.cc", + ], + hdrs = [ + "comfort_noise_generator.h", + ], + deps = [ + ":dsp_utils", + ":generative_model_interface", + ":log_mel_spectrogram_extractor_impl", + "@com_google_absl//absl/memory", + "@com_google_absl//absl/random", + "@com_google_absl//absl/types:span", + "@com_google_audio_dsp//audio/dsp:number_util", + "@com_google_audio_dsp//audio/dsp/mfcc", + "@com_google_audio_dsp//audio/dsp/spectrogram:inverse_spectrogram", + "@com_google_glog//:glog", + ], +) + +cc_library( + name = "lyra_encoder", + srcs = [ + "lyra_encoder.cc", + ], + hdrs = [ + "lyra_encoder.h", + ], + visibility = ["//visibility:public"], + deps = [ + ":feature_extractor_interface", + ":lyra_components", + ":lyra_config", + ":lyra_encoder_interface", + ":noise_estimator", + ":noise_estimator_interface", + ":packet", + ":packet_interface", + ":resampler", + ":resampler_interface", + ":vector_quantizer_interface", + "@com_google_absl//absl/memory", + "@com_google_absl//absl/status", + "@com_google_absl//absl/types:span", + "@com_google_glog//:glog", + "@gulrak_filesystem//:filesystem", + ], +) + +cc_library( + name = "noise_estimator", + srcs = [ + "noise_estimator.cc", + ], + hdrs = [ + "noise_estimator.h", + ], + deps = [ + ":log_mel_spectrogram_extractor_impl", + ":noise_estimator_interface", + "@com_google_absl//absl/memory", + "@com_google_absl//absl/types:span", + "@com_google_audio_dsp//audio/dsp:signal_vector_util", + "@com_google_glog//:glog", + ], +) + +cc_library( + name = "noise_estimator_interface", + hdrs = [ + "noise_estimator_interface.h", + ], + deps = [ + "@com_google_absl//absl/types:span", + ], +) + +cc_library( + name = "packet_loss_model_interface", + hdrs = ["packet_loss_model_interface.h"], + deps = [], +) + +cc_library( + name = "fixed_packet_loss_model", + srcs = [ + "fixed_packet_loss_model.cc", + ], + hdrs = [ + "fixed_packet_loss_model.h", + ], + deps = [":packet_loss_model_interface"], +) + +cc_library( + name = "gilbert_model", + srcs = [ + "gilbert_model.cc", + ], + hdrs = [ + "gilbert_model.h", + ], + deps = [ + ":packet_loss_model_interface", + "@com_google_absl//absl/memory", + "@com_google_glog//:glog", + ], +) + +cc_library( + name = "lyra_config", + srcs = ["lyra_config.cc"], + hdrs = ["lyra_config.h"], + deps = [ + ":lyra_config_cc_proto", + "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/status", + "@com_google_absl//absl/strings", + "@com_google_absl//absl/strings:str_format", + "@com_google_glog//:glog", + "@gulrak_filesystem//:filesystem", + ], +) + +proto_library( + name = "lyra_config_proto", + srcs = ["lyra_config.proto"], +) + +cc_proto_library( + name = "lyra_config_cc_proto", + deps = [":lyra_config_proto"], +) + +cc_library( + name = "lyra_components", + srcs = [ + "lyra_components.cc", + ], + hdrs = [ + "lyra_components.h", + ], + deps = [ + ":feature_estimator_interface", + ":feature_extractor_interface", + ":generative_model_interface", + ":lyra_gan_model", + ":packet", + ":packet_interface", + ":residual_vector_quantizer", + ":soundstream_encoder", + ":vector_quantizer_interface", + ":zero_feature_estimator", + "@gulrak_filesystem//:filesystem", + ], +) + +cc_library( + name = "log_mel_spectrogram_extractor_impl", + srcs = [ + "log_mel_spectrogram_extractor_impl.cc", + ], + hdrs = [ + "log_mel_spectrogram_extractor_impl.h", + ], + deps = [ + ":feature_extractor_interface", + "@com_google_absl//absl/memory", + "@com_google_absl//absl/types:span", + "@com_google_audio_dsp//audio/dsp:number_util", + "@com_google_audio_dsp//audio/dsp/mfcc", + "@com_google_audio_dsp//audio/dsp/spectrogram", + "@com_google_glog//:glog", + ], +) + +cc_library( + name = "soundstream_encoder", + srcs = [ + "soundstream_encoder.cc", + ], + hdrs = [ + "soundstream_encoder.h", + ], + data = ["model_coeffs/soundstream_encoder.tflite"], + deps = [ + ":dsp_utils", + ":feature_extractor_interface", + ":tflite_model_wrapper", + "@com_google_absl//absl/memory", + "@com_google_absl//absl/types:span", + "@com_google_glog//:glog", + "@gulrak_filesystem//:filesystem", + ], +) + +cc_library( + name = "residual_vector_quantizer", + srcs = [ + "residual_vector_quantizer.cc", + ], + hdrs = [ + "residual_vector_quantizer.h", + ], + data = [ + "model_coeffs/quantizer.tflite", + ], + deps = [ + ":tflite_model_wrapper", + ":vector_quantizer_interface", + "@com_google_absl//absl/memory", + "@com_google_glog//:glog", + "@gulrak_filesystem//:filesystem", + ], +) + +cc_library( + name = "packet_interface", + hdrs = [ + "packet_interface.h", + ], + deps = [ + "@com_google_absl//absl/types:span", + ], +) + +cc_library( + name = "packet", + hdrs = ["packet.h"], + deps = [ + ":packet_interface", + "@com_google_absl//absl/memory", + "@com_google_absl//absl/types:span", + "@com_google_glog//:glog", + ], +) + +cc_library( + name = "buffered_filter_interface", + hdrs = ["buffered_filter_interface.h"], +) + +cc_library( + name = "buffered_resampler", + srcs = ["buffered_resampler.cc"], + hdrs = ["buffered_resampler.h"], + deps = [ + ":buffered_filter_interface", + ":resampler", + ":resampler_interface", + "@com_google_absl//absl/memory", + "@com_google_glog//:glog", + ], +) + +cc_test( + name = "buffered_resampler_test", + srcs = ["buffered_resampler_test.cc"], + deps = [ + ":buffered_resampler", + ":lyra_config", + ":resampler_interface", + "//lyra/testing:mock_resampler", + "@com_google_absl//absl/types:span", + "@com_google_googletest//:gtest_main", + ], +) + +cc_library( + name = "preprocessor_interface", + hdrs = [ + "preprocessor_interface.h", + ], + deps = [ + "@com_google_absl//absl/types:span", + ], +) + +cc_library( + name = "no_op_preprocessor", + hdrs = [ + "no_op_preprocessor.h", + ], + deps = [ + ":preprocessor_interface", + "@com_google_absl//absl/types:span", + ], +) + +cc_test( + name = "no_op_preprocessor_test", + size = "small", + srcs = ["no_op_preprocessor_test.cc"], + deps = [ + ":no_op_preprocessor", + "@com_google_absl//absl/types:span", + "@com_google_googletest//:gtest_main", + ], +) + +cc_binary( + name = "lyra_benchmark", + srcs = [ + "lyra_benchmark.cc", + ], + linkopts = select({ + ":android_config": ["-landroid"], + "//conditions:default": [], + }), + deps = [ + ":lyra_benchmark_lib", + "@com_google_absl//absl/flags:flag", + "@com_google_absl//absl/flags:parse", + "@com_google_absl//absl/flags:usage", + "@com_google_absl//absl/strings", + ], +) + +cc_test( + name = "lyra_decoder_test", + size = "large", + srcs = ["lyra_decoder_test.cc"], + data = [":tflite_testdata"], + shard_count = 8, + deps = [ + ":buffered_filter_interface", + ":buffered_resampler", + ":dsp_utils", + ":feature_estimator_interface", + ":generative_model_interface", + ":lyra_components", + ":lyra_config", + ":lyra_decoder", + ":packet_interface", + ":resampler", + ":vector_quantizer_interface", + "//lyra/testing:mock_generative_model", + "//lyra/testing:mock_noise_estimator", + "//lyra/testing:mock_vector_quantizer", + "@com_google_absl//absl/strings", + "@com_google_absl//absl/types:span", + "@com_google_googletest//:gtest_main", + "@gulrak_filesystem//:filesystem", + ], +) + +cc_test( + name = "comfort_noise_generator_test", + size = "small", + srcs = ["comfort_noise_generator_test.cc"], + deps = [ + ":comfort_noise_generator", + ":dsp_utils", + ":log_mel_spectrogram_extractor_impl", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "lyra_gan_model_test", + srcs = ["lyra_gan_model_test.cc"], + deps = [ + ":lyra_config", + ":lyra_gan_model", + "@com_google_googletest//:gtest_main", + "@gulrak_filesystem//:filesystem", + ], +) + +cc_test( + name = "lyra_integration_test", + size = "small", + timeout = "long", + srcs = ["lyra_integration_test.cc"], + data = [ + ":tflite_testdata", + "//lyra/testdata:sample1_16kHz.wav", + "//lyra/testdata:sample1_32kHz.wav", + "//lyra/testdata:sample1_48kHz.wav", + "//lyra/testdata:sample1_8kHz.wav", + ], + shard_count = 4, + deps = [ + ":dsp_utils", + ":log_mel_spectrogram_extractor_impl", + ":lyra_config", + ":lyra_decoder", + ":lyra_encoder", + ":wav_utils", + "@com_google_absl//absl/status:statusor", + "@com_google_absl//absl/strings", + "@com_google_absl//absl/types:span", + "@com_google_googletest//:gtest_main", + "@gulrak_filesystem//:filesystem", + ], +) + +cc_test( + name = "noise_estimator_test", + size = "small", + srcs = ["noise_estimator_test.cc"], + deps = [ + ":comfort_noise_generator", + ":dsp_utils", + ":log_mel_spectrogram_extractor_impl", + ":lyra_config", + ":noise_estimator", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "fixed_packet_loss_model_test", + size = "small", + srcs = ["fixed_packet_loss_model_test.cc"], + deps = [ + ":fixed_packet_loss_model", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "gilbert_model_test", + size = "small", + srcs = ["gilbert_model_test.cc"], + deps = [ + ":gilbert_model", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "log_mel_spectrogram_extractor_impl_test", + size = "small", + srcs = ["log_mel_spectrogram_extractor_impl_test.cc"], + deps = [ + ":log_mel_spectrogram_extractor_impl", + "@com_google_absl//absl/types:span", + "@com_google_googletest//:gtest_main", + ], +) + +cc_binary( + name = "log_mel_spectrogram_extractor_impl_benchmark", + testonly = 1, + srcs = ["log_mel_spectrogram_extractor_impl_benchmark.cc"], + deps = [ + ":log_mel_spectrogram_extractor_impl", + "@com_github_google_benchmark//:benchmark", + "@com_github_google_benchmark//:benchmark_main", + "@com_google_absl//absl/random", + "@com_google_absl//absl/types:span", + ], +) + +cc_test( + name = "soundstream_encoder_test", + srcs = ["soundstream_encoder_test.cc"], + deps = [ + ":lyra_config", + ":soundstream_encoder", + "@com_google_googletest//:gtest_main", + "@gulrak_filesystem//:filesystem", + ], +) + +cc_test( + name = "lyra_encoder_test", + size = "small", + srcs = ["lyra_encoder_test.cc"], + data = [":tflite_testdata"], + shard_count = 8, + deps = [ + ":feature_extractor_interface", + ":lyra_config", + ":lyra_encoder", + ":noise_estimator_interface", + ":packet", + ":resampler_interface", + ":vector_quantizer_interface", + "//lyra/testing:mock_feature_extractor", + "//lyra/testing:mock_noise_estimator", + "//lyra/testing:mock_resampler", + "//lyra/testing:mock_vector_quantizer", + "@com_google_absl//absl/types:span", + "@com_google_googletest//:gtest_main", + "@gulrak_filesystem//:filesystem", + ], +) + +cc_test( + name = "residual_vector_quantizer_test", + size = "small", + srcs = [ + "residual_vector_quantizer_test.cc", + ], + deps = [ + ":log_mel_spectrogram_extractor_impl", + ":lyra_config", + ":residual_vector_quantizer", + "@com_google_googletest//:gtest_main", + "@gulrak_filesystem//:filesystem", + ], +) + +cc_test( + name = "packet_test", + size = "small", + srcs = ["packet_test.cc"], + deps = [ + ":packet", + "@com_google_absl//absl/types:span", + "@com_google_googletest//:gtest_main", + ], +) + +cc_library( + name = "resampler", + srcs = [ + "resampler.cc", + ], + hdrs = ["resampler.h"], + deps = [ + ":dsp_utils", + ":resampler_interface", + "@com_google_absl//absl/memory", + "@com_google_absl//absl/types:span", + "@com_google_audio_dsp//audio/dsp:resampler_q", + "@com_google_glog//:glog", + ], +) + +cc_test( + name = "resampler_test", + size = "small", + srcs = ["resampler_test.cc"], + deps = [ + ":lyra_config", + ":resampler", + "@com_google_absl//absl/types:span", + "@com_google_audio_dsp//audio/dsp:signal_vector_util", + "@com_google_googletest//:gtest_main", + ], +) + +cc_library( + name = "dsp_utils", + srcs = [ + "dsp_utils.cc", + ], + hdrs = ["dsp_utils.h"], + deps = [ + "@com_google_absl//absl/types:span", + "@com_google_audio_dsp//audio/dsp:signal_vector_util", + "@com_google_glog//:glog", + ], +) + +cc_library( + name = "wav_utils", + srcs = [ + "wav_utils.cc", + ], + hdrs = ["wav_utils.h"], + deps = [ + "@com_google_absl//absl/status", + "@com_google_absl//absl/status:statusor", + "@com_google_absl//absl/strings", + "@com_google_audio_dsp//audio/dsp/portable:read_wav_file", + "@com_google_audio_dsp//audio/dsp/portable:write_wav_file", + ], +) + +cc_library( + name = "tflite_model_wrapper", + srcs = [ + "tflite_model_wrapper.cc", + ], + hdrs = [ + "tflite_model_wrapper.h", + ], + deps = [ + "@com_google_absl//absl/memory", + "@com_google_absl//absl/types:span", + "@com_google_glog//:glog", + "@gulrak_filesystem//:filesystem", + "@org_tensorflow//tensorflow/lite:framework", + "@org_tensorflow//tensorflow/lite/delegates/xnnpack:xnnpack_delegate", + "@org_tensorflow//tensorflow/lite/kernels:builtin_ops", + ], +) + +cc_test( + name = "wav_utils_test", + size = "small", + srcs = ["wav_utils_test.cc"], + data = [ + "//lyra/testdata:invalid.wav", + "//lyra/testdata:sample1_16kHz.wav", + ], + deps = [ + ":wav_utils", + "@com_google_absl//absl/flags:flag", + "@com_google_absl//absl/status", + "@com_google_absl//absl/status:statusor", + "@com_google_googletest//:gtest_main", + "@gulrak_filesystem//:filesystem", + ], +) + +cc_test( + name = "dsp_utils_test", + size = "small", + srcs = ["dsp_utils_test.cc"], + deps = [ + ":dsp_utils", + "@com_google_absl//absl/types:span", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "tflite_model_wrapper_test", + srcs = ["tflite_model_wrapper_test.cc"], + data = ["model_coeffs/lyragan.tflite"], + deps = [ + ":tflite_model_wrapper", + "@com_google_absl//absl/types:span", + "@com_google_googletest//:gtest_main", + "@gulrak_filesystem//:filesystem", + "@org_tensorflow//tensorflow/lite:framework", + ], +) + +cc_test( + name = "lyra_config_test", + srcs = ["lyra_config_test.cc"], + data = [":tflite_testdata"], + deps = [ + ":lyra_config", + ":lyra_config_cc_proto", + "@com_google_absl//absl/flags:flag", + "@com_google_absl//absl/status", + "@com_google_googletest//:gtest_main", + "@gulrak_filesystem//:filesystem", + ], +) + +filegroup( + name = "tflite_testdata", + data = glob([ + "model_coeffs/*", + ]), +) + +filegroup( + name = "android_example_assets", + srcs = glob([ + "model_coeffs/*.tflite", + ]) + ["model_coeffs/lyra_config.binarypb"], +) diff --git a/android_example/AndroidManifest.xml b/lyra/android_example/AndroidManifest.xml similarity index 100% rename from android_example/AndroidManifest.xml rename to lyra/android_example/AndroidManifest.xml diff --git a/android_example/BUILD b/lyra/android_example/BUILD similarity index 82% rename from android_example/BUILD rename to lyra/android_example/BUILD index 9aab3da0..d594745a 100644 --- a/android_example/BUILD +++ b/lyra/android_example/BUILD @@ -19,10 +19,10 @@ cc_library( "-llog", ], deps = [ - "//:decoder_main_lib", - "//:encoder_main_lib", - "//:lyra_benchmark_lib", - "//:lyra_config", + "//lyra:lyra_benchmark_lib", + "//lyra:lyra_config", + "//lyra/cli_example:decoder_main_lib", + "//lyra/cli_example:encoder_main_lib", "@com_google_absl//absl/random", ], alwayslink = True, @@ -30,7 +30,7 @@ cc_library( android_library( name = "lyra_android_lib", - srcs = ["//android_example/java/com/example/android/lyra:MainActivity.java"], + srcs = ["//lyra/android_example/java/com/example/android/lyra:MainActivity.java"], custom_package = "com.example.android.lyra", manifest = "LibraryManifest.xml", resource_files = glob(["res/**/*"]), @@ -46,7 +46,7 @@ android_library( filegroup( name = "assets", - srcs = ["//:android_example_assets"], + srcs = ["//lyra:android_example_assets"], ) android_binary( diff --git a/android_example/LibraryManifest.xml b/lyra/android_example/LibraryManifest.xml similarity index 93% rename from android_example/LibraryManifest.xml rename to lyra/android_example/LibraryManifest.xml index 7b30f000..a123293e 100644 --- a/android_example/LibraryManifest.xml +++ b/lyra/android_example/LibraryManifest.xml @@ -27,7 +27,8 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> - + diff --git a/android_example/java/com/example/android/lyra/BUILD b/lyra/android_example/java/com/example/android/lyra/BUILD similarity index 51% rename from android_example/java/com/example/android/lyra/BUILD rename to lyra/android_example/java/com/example/android/lyra/BUILD index a53e6ad6..9fda6311 100644 --- a/android_example/java/com/example/android/lyra/BUILD +++ b/lyra/android_example/java/com/example/android/lyra/BUILD @@ -2,5 +2,5 @@ licenses(["notice"]) exports_files( ["MainActivity.java"], - visibility = ["//android_example:__subpackages__"], + visibility = ["//lyra/android_example:__subpackages__"], ) diff --git a/android_example/java/com/example/android/lyra/MainActivity.java b/lyra/android_example/java/com/example/android/lyra/MainActivity.java similarity index 97% rename from android_example/java/com/example/android/lyra/MainActivity.java rename to lyra/android_example/java/com/example/android/lyra/MainActivity.java index f5356d22..9ec678cf 100644 --- a/android_example/java/com/example/android/lyra/MainActivity.java +++ b/lyra/android_example/java/com/example/android/lyra/MainActivity.java @@ -182,7 +182,7 @@ private void stopRecording() { isRecording = false; // Notify we stopped recording. Button button = (Button) findViewById(R.id.button_record); - button.post(() -> button.setText("Record from microphone")); + button.post(() -> button.setText(R.string.button_record)); Button decodeButton = (Button) findViewById(R.id.button_decode); decodeButton.setEnabled(true); } @@ -217,7 +217,7 @@ public void onMicButtonClicked(View view) { if (!isRecording) { isRecording = true; // Begin recording, and set the button to be a stop button. - ((Button) view).setText("Stop recording"); + ((Button) view).setText(R.string.button_stop); Button decodeButton = (Button) findViewById(R.id.button_decode); decodeButton.setEnabled(false); record = @@ -244,7 +244,7 @@ public void runBenchmark(View view) { TextView tv = (TextView) findViewById(R.id.sample_text); Button button = (Button) view; button.setEnabled(false); - tv.setText("Benchmark in progress. See logcat output for progress."); + tv.setText(R.string.benchmark_in_progress); hasStartedDecode = true; new Thread( @@ -254,7 +254,7 @@ public void runBenchmark(View view) { // thread. lyraBenchmark(2000, weightsDirectory); Log.i(TAG, "Finished lyraBenchmark()"); - tv.post(() -> tv.setText("Finished benchmarking. See logcat for results.")); + tv.post(() -> tv.setText(R.string.benchmark_finished)); button.post(() -> button.setEnabled(true)); hasStartedDecode = false; }) diff --git a/android_example/jni_lyra_benchmark_lib.cc b/lyra/android_example/jni_lyra_benchmark_lib.cc similarity index 94% rename from android_example/jni_lyra_benchmark_lib.cc rename to lyra/android_example/jni_lyra_benchmark_lib.cc index d3473cb8..0d6dde9d 100644 --- a/android_example/jni_lyra_benchmark_lib.cc +++ b/lyra/android_example/jni_lyra_benchmark_lib.cc @@ -18,10 +18,10 @@ #include #include "absl/random/random.h" -#include "decoder_main_lib.h" -#include "encoder_main_lib.h" -#include "lyra_benchmark_lib.h" -#include "lyra_config.h" +#include "lyra/cli_example/decoder_main_lib.h" +#include "lyra/cli_example/encoder_main_lib.h" +#include "lyra/lyra_benchmark_lib.h" +#include "lyra/lyra_config.h" extern "C" JNIEXPORT jshortArray JNICALL Java_com_example_android_lyra_MainActivity_encodeAndDecodeSamples( diff --git a/android_example/res/drawable-v24/ic_launcher_foreground.xml b/lyra/android_example/res/drawable-v24/ic_launcher_foreground.xml similarity index 100% rename from android_example/res/drawable-v24/ic_launcher_foreground.xml rename to lyra/android_example/res/drawable-v24/ic_launcher_foreground.xml diff --git a/android_example/res/drawable/ic_launcher_background.xml b/lyra/android_example/res/drawable/ic_launcher_background.xml similarity index 100% rename from android_example/res/drawable/ic_launcher_background.xml rename to lyra/android_example/res/drawable/ic_launcher_background.xml diff --git a/android_example/res/layout/activity_main.xml b/lyra/android_example/res/layout/activity_main.xml similarity index 100% rename from android_example/res/layout/activity_main.xml rename to lyra/android_example/res/layout/activity_main.xml diff --git a/android_example/res/mipmap-anydpi-v26/ic_launcher.xml b/lyra/android_example/res/mipmap-anydpi-v26/ic_launcher.xml similarity index 100% rename from android_example/res/mipmap-anydpi-v26/ic_launcher.xml rename to lyra/android_example/res/mipmap-anydpi-v26/ic_launcher.xml diff --git a/android_example/res/mipmap-anydpi-v26/ic_launcher_round.xml b/lyra/android_example/res/mipmap-anydpi-v26/ic_launcher_round.xml similarity index 100% rename from android_example/res/mipmap-anydpi-v26/ic_launcher_round.xml rename to lyra/android_example/res/mipmap-anydpi-v26/ic_launcher_round.xml diff --git a/android_example/res/mipmap-hdpi/ic_launcher.png b/lyra/android_example/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from android_example/res/mipmap-hdpi/ic_launcher.png rename to lyra/android_example/res/mipmap-hdpi/ic_launcher.png diff --git a/android_example/res/mipmap-hdpi/ic_launcher_round.png b/lyra/android_example/res/mipmap-hdpi/ic_launcher_round.png similarity index 100% rename from android_example/res/mipmap-hdpi/ic_launcher_round.png rename to lyra/android_example/res/mipmap-hdpi/ic_launcher_round.png diff --git a/android_example/res/mipmap-mdpi/ic_launcher.png b/lyra/android_example/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from android_example/res/mipmap-mdpi/ic_launcher.png rename to lyra/android_example/res/mipmap-mdpi/ic_launcher.png diff --git a/android_example/res/mipmap-mdpi/ic_launcher_round.png b/lyra/android_example/res/mipmap-mdpi/ic_launcher_round.png similarity index 100% rename from android_example/res/mipmap-mdpi/ic_launcher_round.png rename to lyra/android_example/res/mipmap-mdpi/ic_launcher_round.png diff --git a/android_example/res/mipmap-xhdpi/ic_launcher.png b/lyra/android_example/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from android_example/res/mipmap-xhdpi/ic_launcher.png rename to lyra/android_example/res/mipmap-xhdpi/ic_launcher.png diff --git a/android_example/res/mipmap-xhdpi/ic_launcher_round.png b/lyra/android_example/res/mipmap-xhdpi/ic_launcher_round.png similarity index 100% rename from android_example/res/mipmap-xhdpi/ic_launcher_round.png rename to lyra/android_example/res/mipmap-xhdpi/ic_launcher_round.png diff --git a/android_example/res/mipmap-xxhdpi/ic_launcher.png b/lyra/android_example/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from android_example/res/mipmap-xxhdpi/ic_launcher.png rename to lyra/android_example/res/mipmap-xxhdpi/ic_launcher.png diff --git a/android_example/res/mipmap-xxhdpi/ic_launcher_round.png b/lyra/android_example/res/mipmap-xxhdpi/ic_launcher_round.png similarity index 100% rename from android_example/res/mipmap-xxhdpi/ic_launcher_round.png rename to lyra/android_example/res/mipmap-xxhdpi/ic_launcher_round.png diff --git a/android_example/res/mipmap-xxxhdpi/ic_launcher.png b/lyra/android_example/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from android_example/res/mipmap-xxxhdpi/ic_launcher.png rename to lyra/android_example/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/android_example/res/mipmap-xxxhdpi/ic_launcher_round.png b/lyra/android_example/res/mipmap-xxxhdpi/ic_launcher_round.png similarity index 100% rename from android_example/res/mipmap-xxxhdpi/ic_launcher_round.png rename to lyra/android_example/res/mipmap-xxxhdpi/ic_launcher_round.png diff --git a/android_example/res/values/colors.xml b/lyra/android_example/res/values/colors.xml similarity index 100% rename from android_example/res/values/colors.xml rename to lyra/android_example/res/values/colors.xml diff --git a/android_example/res/values/strings.xml b/lyra/android_example/res/values/strings.xml similarity index 67% rename from android_example/res/values/strings.xml rename to lyra/android_example/res/values/strings.xml index a1398281..a2453fba 100644 --- a/android_example/res/values/strings.xml +++ b/lyra/android_example/res/values/strings.xml @@ -23,4 +23,10 @@ description="Label for button to run benchmarks [CHAR_LIMIT=100]">Benchmark Encode/decode to speaker + Stop recording + Benchmark in progress. See logcat output for progress. + Finished benchmarking. See logcat for results. diff --git a/android_example/res/values/styles.xml b/lyra/android_example/res/values/styles.xml similarity index 100% rename from android_example/res/values/styles.xml rename to lyra/android_example/res/values/styles.xml diff --git a/architecture_utils.h b/lyra/architecture_utils.h similarity index 87% rename from architecture_utils.h rename to lyra/architecture_utils.h index bde4f88a..c4bddbc5 100644 --- a/architecture_utils.h +++ b/lyra/architecture_utils.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_ARCHITECTURE_UTILS_H_ -#define LYRA_CODEC_ARCHITECTURE_UTILS_H_ +#ifndef LYRA_ARCHITECTURE_UTILS_H_ +#define LYRA_ARCHITECTURE_UTILS_H_ // Placeholder for get runfiles header. #include "include/ghc/filesystem.hpp" @@ -31,4 +31,4 @@ ghc::filesystem::path GetCompleteArchitecturePath( } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_ARCHITECTURE_UTILS_H_ +#endif // LYRA_ARCHITECTURE_UTILS_H_ diff --git a/buffered_filter_interface.h b/lyra/buffered_filter_interface.h similarity index 88% rename from buffered_filter_interface.h rename to lyra/buffered_filter_interface.h index dee49d7e..99af6720 100644 --- a/buffered_filter_interface.h +++ b/lyra/buffered_filter_interface.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_BUFFERED_FILTER_INTERFACE_H_ -#define LYRA_CODEC_BUFFERED_FILTER_INTERFACE_H_ +#ifndef LYRA_BUFFERED_FILTER_INTERFACE_H_ +#define LYRA_BUFFERED_FILTER_INTERFACE_H_ #include #include @@ -39,4 +39,4 @@ class BufferedFilterInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_BUFFERED_FILTER_INTERFACE_H_ +#endif // LYRA_BUFFERED_FILTER_INTERFACE_H_ diff --git a/buffered_resampler.cc b/lyra/buffered_resampler.cc similarity index 98% rename from buffered_resampler.cc rename to lyra/buffered_resampler.cc index d484a4e4..918fc947 100644 --- a/buffered_resampler.cc +++ b/lyra/buffered_resampler.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "buffered_resampler.h" +#include "lyra/buffered_resampler.h" #include #include @@ -25,7 +25,7 @@ #include "absl/memory/memory.h" #include "glog/logging.h" // IWYU pragma: keep -#include "resampler.h" +#include "lyra/resampler.h" namespace chromemedia { namespace codec { diff --git a/buffered_resampler.h b/lyra/buffered_resampler.h similarity index 93% rename from buffered_resampler.h rename to lyra/buffered_resampler.h index 4665d47f..e98ddf10 100644 --- a/buffered_resampler.h +++ b/lyra/buffered_resampler.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_BUFFERED_RESAMPLER_H_ -#define LYRA_CODEC_BUFFERED_RESAMPLER_H_ +#ifndef LYRA_BUFFERED_RESAMPLER_H_ +#define LYRA_BUFFERED_RESAMPLER_H_ #include #include @@ -23,8 +23,8 @@ #include #include -#include "buffered_filter_interface.h" -#include "resampler_interface.h" +#include "lyra/buffered_filter_interface.h" +#include "lyra/resampler_interface.h" namespace chromemedia { namespace codec { @@ -78,4 +78,4 @@ class BufferedResampler : public BufferedFilterInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_BUFFERED_RESAMPLER_H_ +#endif // LYRA_BUFFERED_RESAMPLER_H_ diff --git a/buffered_resampler_test.cc b/lyra/buffered_resampler_test.cc similarity index 98% rename from buffered_resampler_test.cc rename to lyra/buffered_resampler_test.cc index 216e8a30..0569e3c0 100644 --- a/buffered_resampler_test.cc +++ b/lyra/buffered_resampler_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "buffered_resampler.h" +#include "lyra/buffered_resampler.h" #include #include @@ -25,9 +25,9 @@ #include "absl/types/span.h" #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "lyra_config.h" -#include "resampler_interface.h" -#include "testing/mock_resampler.h" +#include "lyra/lyra_config.h" +#include "lyra/resampler_interface.h" +#include "lyra/testing/mock_resampler.h" namespace chromemedia { namespace codec { diff --git a/lyra/cli_example/BUILD b/lyra/cli_example/BUILD new file mode 100644 index 00000000..8c4a9c3b --- /dev/null +++ b/lyra/cli_example/BUILD @@ -0,0 +1,150 @@ +package(default_visibility = ["//visibility:public"]) + +exports_files( + srcs = [ + "decoder_main.cc", + "decoder_main_lib.cc", + "decoder_main_lib.h", + "encoder_main.cc", + "encoder_main_lib.cc", + "encoder_main_lib.h", + ], +) + +cc_library( + name = "encoder_main_lib", + srcs = [ + "encoder_main_lib.cc", + ], + hdrs = [ + "encoder_main_lib.h", + ], + deps = [ + "//lyra:lyra_config", + "//lyra:lyra_encoder", + "//lyra:no_op_preprocessor", + "//lyra:wav_utils", + "@com_google_absl//absl/status", + "@com_google_absl//absl/status:statusor", + "@com_google_absl//absl/strings", + "@com_google_absl//absl/time", + "@com_google_absl//absl/types:span", + "@com_google_glog//:glog", + "@gulrak_filesystem//:filesystem", + ], +) + +cc_library( + name = "decoder_main_lib", + srcs = [ + "decoder_main_lib.cc", + ], + hdrs = [ + "decoder_main_lib.h", + ], + deps = [ + "//lyra:fixed_packet_loss_model", + "//lyra:gilbert_model", + "//lyra:lyra_config", + "//lyra:lyra_decoder", + "//lyra:packet_loss_model_interface", + "//lyra:wav_utils", + "@com_google_absl//absl/flags:marshalling", + "@com_google_absl//absl/random", + "@com_google_absl//absl/random:bit_gen_ref", + "@com_google_absl//absl/status", + "@com_google_absl//absl/strings", + "@com_google_absl//absl/time", + "@com_google_absl//absl/types:span", + "@com_google_glog//:glog", + "@gulrak_filesystem//:filesystem", + ], +) + +cc_test( + name = "encoder_main_lib_test", + size = "small", + srcs = ["encoder_main_lib_test.cc"], + data = [ + "//lyra:tflite_testdata", + "//lyra/testdata:sample1_16kHz.wav", + "//lyra/testdata:sample1_32kHz.wav", + "//lyra/testdata:sample1_48kHz.wav", + "//lyra/testdata:sample1_8kHz.wav", + ], + deps = [ + ":encoder_main_lib", + "@com_google_absl//absl/flags:flag", + "@com_google_absl//absl/strings", + "@com_google_googletest//:gtest_main", + "@gulrak_filesystem//:filesystem", + ], +) + +cc_test( + name = "decoder_main_lib_test", + size = "large", + srcs = ["decoder_main_lib_test.cc"], + data = [ + "//lyra:tflite_testdata", + "//lyra/testdata:incomplete_encoded_packet.lyra", + "//lyra/testdata:no_encoded_packet.lyra", + "//lyra/testdata:one_encoded_packet_16khz.lyra", + "//lyra/testdata:two_encoded_packets_16khz.lyra", + ], + shard_count = 4, + deps = [ + ":decoder_main_lib", + "//lyra:lyra_config", + "//lyra:wav_utils", + "@com_google_absl//absl/flags:flag", + "@com_google_absl//absl/status:statusor", + "@com_google_absl//absl/strings", + "@com_google_googletest//:gtest_main", + "@gulrak_filesystem//:filesystem", + ], +) + +cc_binary( + name = "encoder_main", + srcs = [ + "encoder_main.cc", + ], + data = ["//lyra:tflite_testdata"], + linkopts = select({ + "//lyra:android_config": ["-landroid"], + "//conditions:default": [], + }), + deps = [ + ":encoder_main_lib", + "//lyra:architecture_utils", + "@com_google_absl//absl/flags:flag", + "@com_google_absl//absl/flags:parse", + "@com_google_absl//absl/flags:usage", + "@com_google_absl//absl/strings", + "@com_google_glog//:glog", + "@gulrak_filesystem//:filesystem", + ], +) + +cc_binary( + name = "decoder_main", + srcs = [ + "decoder_main.cc", + ], + data = ["//lyra:tflite_testdata"], + linkopts = select({ + "//lyra:android_config": ["-landroid"], + "//conditions:default": [], + }), + deps = [ + ":decoder_main_lib", + "//lyra:architecture_utils", + "@com_google_absl//absl/flags:flag", + "@com_google_absl//absl/flags:parse", + "@com_google_absl//absl/flags:usage", + "@com_google_absl//absl/strings", + "@com_google_glog//:glog", + "@gulrak_filesystem//:filesystem", + ], +) diff --git a/decoder_main.cc b/lyra/cli_example/decoder_main.cc similarity index 94% rename from decoder_main.cc rename to lyra/cli_example/decoder_main.cc index 72e80adc..f29477ed 100644 --- a/decoder_main.cc +++ b/lyra/cli_example/decoder_main.cc @@ -20,10 +20,10 @@ #include "absl/flags/parse.h" #include "absl/flags/usage.h" #include "absl/strings/string_view.h" -#include "architecture_utils.h" -#include "decoder_main_lib.h" #include "glog/logging.h" // IWYU pragma: keep #include "include/ghc/filesystem.hpp" +#include "lyra/architecture_utils.h" +#include "lyra/cli_example/decoder_main_lib.h" ABSL_FLAG(std::string, encoded_path, "", "Complete path to the file containing the encoded features."); @@ -50,12 +50,11 @@ ABSL_FLAG(chromemedia::codec::PacketLossPattern, fixed_packet_loss_pattern, "bursts will be rounded up to the nearest packet duration boundary. " "If this flag contains a nonzero number of values we ignore " "|packet_loss_rate| and |average_burst_length|."); -ABSL_FLAG(std::string, model_path, "model_coeffs", +ABSL_FLAG(std::string, model_path, "lyra/model_coeffs", "Path to directory containing TFLite files. For mobile this is the " "absolute path, like " - "'/data/local/tmp/model_coeffs/'. For " - "desktop " - "this is the path relative to the binary."); + "'/data/local/tmp/lyra/model_coeffs/'." + " For desktop this is the path relative to the binary."); int main(int argc, char** argv) { absl::SetProgramUsageMessage(argv[0]); diff --git a/decoder_main_lib.cc b/lyra/cli_example/decoder_main_lib.cc similarity index 97% rename from decoder_main_lib.cc rename to lyra/cli_example/decoder_main_lib.cc index 89dc2864..61974393 100644 --- a/decoder_main_lib.cc +++ b/lyra/cli_example/decoder_main_lib.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "decoder_main_lib.h" +#include "lyra/cli_example/decoder_main_lib.h" #include #include @@ -33,13 +33,13 @@ #include "absl/time/clock.h" #include "absl/time/time.h" #include "absl/types/span.h" -#include "fixed_packet_loss_model.h" -#include "gilbert_model.h" #include "glog/logging.h" // IWYU pragma: keep #include "include/ghc/filesystem.hpp" -#include "lyra_config.h" -#include "lyra_decoder.h" -#include "wav_utils.h" +#include "lyra/fixed_packet_loss_model.h" +#include "lyra/gilbert_model.h" +#include "lyra/lyra_config.h" +#include "lyra/lyra_decoder.h" +#include "lyra/wav_utils.h" namespace chromemedia { namespace codec { diff --git a/decoder_main_lib.h b/lyra/cli_example/decoder_main_lib.h similarity index 92% rename from decoder_main_lib.h rename to lyra/cli_example/decoder_main_lib.h index 1b93118b..81f4c1c0 100644 --- a/decoder_main_lib.h +++ b/lyra/cli_example/decoder_main_lib.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_DECODER_MAIN_LIB_H_ -#define LYRA_CODEC_DECODER_MAIN_LIB_H_ +#ifndef LYRA_CLI_EXAMPLE_DECODER_MAIN_LIB_H_ +#define LYRA_CLI_EXAMPLE_DECODER_MAIN_LIB_H_ #include #include @@ -24,8 +24,8 @@ #include "absl/random/bit_gen_ref.h" #include "absl/strings/string_view.h" #include "include/ghc/filesystem.hpp" -#include "lyra_decoder.h" -#include "packet_loss_model_interface.h" +#include "lyra/lyra_decoder.h" +#include "lyra/packet_loss_model_interface.h" namespace chromemedia { namespace codec { @@ -71,4 +71,4 @@ bool DecodeFile(const ghc::filesystem::path& encoded_path, } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_DECODER_MAIN_LIB_H_ +#endif // LYRA_CLI_EXAMPLE_DECODER_MAIN_LIB_H_ diff --git a/decoder_main_lib_test.cc b/lyra/cli_example/decoder_main_lib_test.cc similarity index 96% rename from decoder_main_lib_test.cc rename to lyra/cli_example/decoder_main_lib_test.cc index 9e9e29f7..cf662eb9 100644 --- a/decoder_main_lib_test.cc +++ b/lyra/cli_example/decoder_main_lib_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "decoder_main_lib.h" +#include "lyra/cli_example/decoder_main_lib.h" #include #include // NOLINT(build/c++11) @@ -25,15 +25,15 @@ #include "absl/strings/string_view.h" #include "gtest/gtest.h" #include "include/ghc/filesystem.hpp" -#include "lyra_config.h" -#include "wav_utils.h" +#include "lyra/lyra_config.h" +#include "lyra/wav_utils.h" namespace chromemedia { namespace codec { namespace { -static constexpr absl::string_view kTestdataDir = "testdata"; -static constexpr absl::string_view kExportedModelPath = "model_coeffs"; +static constexpr absl::string_view kTestdataDir = "lyra/testdata"; +static constexpr absl::string_view kExportedModelPath = "lyra/model_coeffs"; class DecoderMainLibTest : public testing::TestWithParam { protected: diff --git a/encoder_main.cc b/lyra/cli_example/encoder_main.cc similarity index 92% rename from encoder_main.cc rename to lyra/cli_example/encoder_main.cc index fda27ab0..d395f156 100644 --- a/encoder_main.cc +++ b/lyra/cli_example/encoder_main.cc @@ -19,10 +19,10 @@ #include "absl/flags/parse.h" #include "absl/flags/usage.h" #include "absl/strings/string_view.h" -#include "architecture_utils.h" -#include "encoder_main_lib.h" #include "glog/logging.h" // IWYU pragma: keep #include "include/ghc/filesystem.hpp" +#include "lyra/architecture_utils.h" +#include "lyra/cli_example/encoder_main_lib.h" ABSL_FLAG(std::string, input_path, "", "Complete path to the WAV file to be encoded."); @@ -40,12 +40,11 @@ ABSL_FLAG(bool, enable_preprocessing, false, ABSL_FLAG(bool, enable_dtx, false, "Enables discontinuous transmission (DTX). DTX does not send packets " "when noise is detected."); -ABSL_FLAG(std::string, model_path, "model_coeffs", +ABSL_FLAG(std::string, model_path, "lyra/model_coeffs", "Path to directory containing TFLite files. For mobile this is the " "absolute path, like " - "'/data/local/tmp/model_coeffs/'. For " - "desktop " - "this is the path relative to the binary."); + "'/data/local/tmp/lyra/model_coeffs/'." + " For desktop this is the path relative to the binary."); int main(int argc, char** argv) { absl::SetProgramUsageMessage(argv[0]); diff --git a/encoder_main_lib.cc b/lyra/cli_example/encoder_main_lib.cc similarity index 96% rename from encoder_main_lib.cc rename to lyra/cli_example/encoder_main_lib.cc index 7915a87a..30ee0348 100644 --- a/encoder_main_lib.cc +++ b/lyra/cli_example/encoder_main_lib.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "encoder_main_lib.h" +#include "lyra/cli_example/encoder_main_lib.h" #include #include @@ -30,10 +30,10 @@ #include "absl/types/span.h" #include "glog/logging.h" // IWYU pragma: keep #include "include/ghc/filesystem.hpp" -#include "lyra_config.h" -#include "lyra_encoder.h" -#include "no_op_preprocessor.h" -#include "wav_utils.h" +#include "lyra/lyra_config.h" +#include "lyra/lyra_encoder.h" +#include "lyra/no_op_preprocessor.h" +#include "lyra/wav_utils.h" namespace chromemedia { namespace codec { diff --git a/encoder_main_lib.h b/lyra/cli_example/encoder_main_lib.h similarity index 92% rename from encoder_main_lib.h rename to lyra/cli_example/encoder_main_lib.h index 30154fcc..69d4852b 100644 --- a/encoder_main_lib.h +++ b/lyra/cli_example/encoder_main_lib.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_ENCODER_MAIN_LIB_H_ -#define LYRA_CODEC_ENCODER_MAIN_LIB_H_ +#ifndef LYRA_CLI_EXAMPLE_ENCODER_MAIN_LIB_H_ +#define LYRA_CLI_EXAMPLE_ENCODER_MAIN_LIB_H_ #include #include @@ -43,4 +43,4 @@ bool EncodeFile(const ghc::filesystem::path& wav_path, } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_ENCODER_MAIN_LIB_H_ +#endif // LYRA_CLI_EXAMPLE_ENCODER_MAIN_LIB_H_ diff --git a/encoder_main_lib_test.cc b/lyra/cli_example/encoder_main_lib_test.cc similarity index 93% rename from encoder_main_lib_test.cc rename to lyra/cli_example/encoder_main_lib_test.cc index b1272659..d40f3d4e 100644 --- a/encoder_main_lib_test.cc +++ b/lyra/cli_example/encoder_main_lib_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "encoder_main_lib.h" +#include "lyra/cli_example/encoder_main_lib.h" #include #include // NOLINT(build/c++11) @@ -31,14 +31,14 @@ namespace { static constexpr absl::string_view kWavFiles[] = { "sample1_8kHz", "sample1_16kHz", "sample1_32kHz", "sample1_48kHz"}; -static constexpr absl::string_view kTestdataDir = "testdata"; +static constexpr absl::string_view kTestdataDir = "lyra/testdata"; class EncoderMainLibTest : public testing::Test { protected: EncoderMainLibTest() : output_dir_(ghc::filesystem::path(testing::TempDir()) / "output"), testdata_dir_(ghc::filesystem::current_path() / kTestdataDir), - model_path_(ghc::filesystem::current_path() / "model_coeffs") {} + model_path_(ghc::filesystem::current_path() / "lyra/model_coeffs") {} void SetUp() override { std::error_code error_code; diff --git a/comfort_noise_generator.cc b/lyra/comfort_noise_generator.cc similarity index 97% rename from comfort_noise_generator.cc rename to lyra/comfort_noise_generator.cc index ca6027ce..33f865d6 100644 --- a/comfort_noise_generator.cc +++ b/lyra/comfort_noise_generator.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "comfort_noise_generator.h" +#include "lyra/comfort_noise_generator.h" #include #include @@ -28,9 +28,9 @@ #include "audio/dsp/mfcc/mel_filterbank.h" #include "audio/dsp/number_util.h" #include "audio/dsp/spectrogram/inverse_spectrogram.h" -#include "dsp_utils.h" #include "glog/logging.h" // IWYU pragma: keep -#include "log_mel_spectrogram_extractor_impl.h" +#include "lyra/dsp_utils.h" +#include "lyra/log_mel_spectrogram_extractor_impl.h" namespace chromemedia { namespace codec { diff --git a/comfort_noise_generator.h b/lyra/comfort_noise_generator.h similarity index 92% rename from comfort_noise_generator.h rename to lyra/comfort_noise_generator.h index 116327dd..15d9a78f 100644 --- a/comfort_noise_generator.h +++ b/lyra/comfort_noise_generator.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_COMFORT_NOISE_GENERATOR_H_ -#define LYRA_CODEC_COMFORT_NOISE_GENERATOR_H_ +#ifndef LYRA_COMFORT_NOISE_GENERATOR_H_ +#define LYRA_COMFORT_NOISE_GENERATOR_H_ #include #include @@ -24,7 +24,7 @@ #include "audio/dsp/mfcc/mel_filterbank.h" #include "audio/dsp/spectrogram/inverse_spectrogram.h" -#include "generative_model_interface.h" +#include "lyra/generative_model_interface.h" namespace chromemedia { namespace codec { @@ -70,4 +70,4 @@ class ComfortNoiseGenerator : public GenerativeModel { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_COMFORT_NOISE_GENERATOR_H_ +#endif // LYRA_COMFORT_NOISE_GENERATOR_H_ diff --git a/comfort_noise_generator_test.cc b/lyra/comfort_noise_generator_test.cc similarity index 97% rename from comfort_noise_generator_test.cc rename to lyra/comfort_noise_generator_test.cc index df93e1d3..e67d94f2 100644 --- a/comfort_noise_generator_test.cc +++ b/lyra/comfort_noise_generator_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "comfort_noise_generator.h" +#include "lyra/comfort_noise_generator.h" #include #include @@ -21,10 +21,10 @@ #include #include -#include "dsp_utils.h" #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "log_mel_spectrogram_extractor_impl.h" +#include "lyra/dsp_utils.h" +#include "lyra/log_mel_spectrogram_extractor_impl.h" namespace chromemedia { namespace codec { diff --git a/dsp_utils.cc b/lyra/dsp_utils.cc similarity index 98% rename from dsp_utils.cc rename to lyra/dsp_utils.cc index 8a52ee9b..c916a30e 100644 --- a/dsp_utils.cc +++ b/lyra/dsp_utils.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "dsp_utils.h" +#include "lyra/dsp_utils.h" #include #include diff --git a/dsp_utils.h b/lyra/dsp_utils.h similarity index 97% rename from dsp_utils.h rename to lyra/dsp_utils.h index 3b223207..e3e1c8fb 100644 --- a/dsp_utils.h +++ b/lyra/dsp_utils.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_DSP_UTILS_H_ -#define LYRA_CODEC_DSP_UTILS_H_ +#ifndef LYRA_DSP_UTILS_H_ +#define LYRA_DSP_UTILS_H_ #include #include @@ -122,4 +122,4 @@ Int16ToUnit(const absl::Span input) { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_DSP_UTILS_H_ +#endif // LYRA_DSP_UTILS_H_ diff --git a/dsp_utils_test.cc b/lyra/dsp_utils_test.cc similarity index 99% rename from dsp_utils_test.cc rename to lyra/dsp_utils_test.cc index 9d9d5821..b667d214 100644 --- a/dsp_utils_test.cc +++ b/lyra/dsp_utils_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "dsp_utils.h" +#include "lyra/dsp_utils.h" #include #include diff --git a/feature_estimator_interface.h b/lyra/feature_estimator_interface.h similarity index 86% rename from feature_estimator_interface.h rename to lyra/feature_estimator_interface.h index 391560cc..98cb46b1 100644 --- a/feature_estimator_interface.h +++ b/lyra/feature_estimator_interface.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_FEATURE_ESTIMATOR_INTERFACE_H_ -#define LYRA_CODEC_FEATURE_ESTIMATOR_INTERFACE_H_ +#ifndef LYRA_FEATURE_ESTIMATOR_INTERFACE_H_ +#define LYRA_FEATURE_ESTIMATOR_INTERFACE_H_ #include @@ -36,4 +36,4 @@ class FeatureEstimatorInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_FEATURE_ESTIMATOR_INTERFACE_H_ +#endif // LYRA_FEATURE_ESTIMATOR_INTERFACE_H_ diff --git a/feature_extractor_interface.h b/lyra/feature_extractor_interface.h similarity index 88% rename from feature_extractor_interface.h rename to lyra/feature_extractor_interface.h index 05a357b6..ed7cc485 100644 --- a/feature_extractor_interface.h +++ b/lyra/feature_extractor_interface.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_FEATURE_EXTRACTOR_INTERFACE_H_ -#define LYRA_CODEC_FEATURE_EXTRACTOR_INTERFACE_H_ +#ifndef LYRA_FEATURE_EXTRACTOR_INTERFACE_H_ +#define LYRA_FEATURE_EXTRACTOR_INTERFACE_H_ #include #include @@ -41,4 +41,4 @@ class FeatureExtractorInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_FEATURE_EXTRACTOR_INTERFACE_H_ +#endif // LYRA_FEATURE_EXTRACTOR_INTERFACE_H_ diff --git a/fixed_packet_loss_model.cc b/lyra/fixed_packet_loss_model.cc similarity index 98% rename from fixed_packet_loss_model.cc rename to lyra/fixed_packet_loss_model.cc index c99c0088..7a50c9a1 100644 --- a/fixed_packet_loss_model.cc +++ b/lyra/fixed_packet_loss_model.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "fixed_packet_loss_model.h" +#include "lyra/fixed_packet_loss_model.h" #include #include diff --git a/fixed_packet_loss_model.h b/lyra/fixed_packet_loss_model.h similarity index 88% rename from fixed_packet_loss_model.h rename to lyra/fixed_packet_loss_model.h index f45e9c6b..8e3603c1 100644 --- a/fixed_packet_loss_model.h +++ b/lyra/fixed_packet_loss_model.h @@ -14,13 +14,13 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_FIXED_PACKET_LOSS_MODEL_H_ -#define LYRA_CODEC_FIXED_PACKET_LOSS_MODEL_H_ +#ifndef LYRA_FIXED_PACKET_LOSS_MODEL_H_ +#define LYRA_FIXED_PACKET_LOSS_MODEL_H_ #include #include -#include "packet_loss_model_interface.h" +#include "lyra/packet_loss_model_interface.h" namespace chromemedia { namespace codec { @@ -45,4 +45,4 @@ class FixedPacketLossModel : public PacketLossModelInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_FIXED_PACKET_LOSS_MODEL_H_ +#endif // LYRA_FIXED_PACKET_LOSS_MODEL_H_ diff --git a/fixed_packet_loss_model_test.cc b/lyra/fixed_packet_loss_model_test.cc similarity index 98% rename from fixed_packet_loss_model_test.cc rename to lyra/fixed_packet_loss_model_test.cc index 5d7548fd..a5ef2d84 100644 --- a/fixed_packet_loss_model_test.cc +++ b/lyra/fixed_packet_loss_model_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "fixed_packet_loss_model.h" +#include "lyra/fixed_packet_loss_model.h" #include #include diff --git a/generative_model_interface.h b/lyra/generative_model_interface.h similarity index 96% rename from generative_model_interface.h rename to lyra/generative_model_interface.h index 4701eb69..eab12929 100644 --- a/generative_model_interface.h +++ b/lyra/generative_model_interface.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_GENERATIVE_MODEL_INTERFACE_H_ -#define LYRA_CODEC_GENERATIVE_MODEL_INTERFACE_H_ +#ifndef LYRA_GENERATIVE_MODEL_INTERFACE_H_ +#define LYRA_GENERATIVE_MODEL_INTERFACE_H_ #include #include @@ -136,4 +136,4 @@ class GenerativeModel : public GenerativeModelInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_GENERATIVE_MODEL_INTERFACE_H_ +#endif // LYRA_GENERATIVE_MODEL_INTERFACE_H_ diff --git a/gilbert_model.cc b/lyra/gilbert_model.cc similarity index 98% rename from gilbert_model.cc rename to lyra/gilbert_model.cc index 2932b27e..ec69cdbd 100644 --- a/gilbert_model.cc +++ b/lyra/gilbert_model.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "gilbert_model.h" +#include "lyra/gilbert_model.h" #include #include diff --git a/gilbert_model.h b/lyra/gilbert_model.h similarity index 92% rename from gilbert_model.h rename to lyra/gilbert_model.h index 13a03c8c..feab7649 100644 --- a/gilbert_model.h +++ b/lyra/gilbert_model.h @@ -14,13 +14,13 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_GILBERT_MODEL_H_ -#define LYRA_CODEC_GILBERT_MODEL_H_ +#ifndef LYRA_GILBERT_MODEL_H_ +#define LYRA_GILBERT_MODEL_H_ #include #include -#include "packet_loss_model_interface.h" +#include "lyra/packet_loss_model_interface.h" namespace chromemedia { namespace codec { @@ -57,4 +57,4 @@ class GilbertModel : public PacketLossModelInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_GILBERT_MODEL_H_ +#endif // LYRA_GILBERT_MODEL_H_ diff --git a/gilbert_model_test.cc b/lyra/gilbert_model_test.cc similarity index 98% rename from gilbert_model_test.cc rename to lyra/gilbert_model_test.cc index c1ef842d..3ee67dbe 100644 --- a/gilbert_model_test.cc +++ b/lyra/gilbert_model_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "gilbert_model.h" +#include "lyra/gilbert_model.h" #include #include diff --git a/log_mel_spectrogram_extractor_impl.cc b/lyra/log_mel_spectrogram_extractor_impl.cc similarity index 99% rename from log_mel_spectrogram_extractor_impl.cc rename to lyra/log_mel_spectrogram_extractor_impl.cc index 580ed90b..69ceb888 100644 --- a/log_mel_spectrogram_extractor_impl.cc +++ b/lyra/log_mel_spectrogram_extractor_impl.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "log_mel_spectrogram_extractor_impl.h" +#include "lyra/log_mel_spectrogram_extractor_impl.h" #include #include diff --git a/log_mel_spectrogram_extractor_impl.h b/lyra/log_mel_spectrogram_extractor_impl.h similarity index 92% rename from log_mel_spectrogram_extractor_impl.h rename to lyra/log_mel_spectrogram_extractor_impl.h index 1817000c..7969fc6a 100644 --- a/log_mel_spectrogram_extractor_impl.h +++ b/lyra/log_mel_spectrogram_extractor_impl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_LOG_MEL_SPECTROGRAM_EXTRACTOR_IMPL_H_ -#define LYRA_CODEC_LOG_MEL_SPECTROGRAM_EXTRACTOR_IMPL_H_ +#ifndef LYRA_LOG_MEL_SPECTROGRAM_EXTRACTOR_IMPL_H_ +#define LYRA_LOG_MEL_SPECTROGRAM_EXTRACTOR_IMPL_H_ #include #include @@ -25,7 +25,7 @@ #include "absl/types/span.h" #include "audio/dsp/mfcc/mel_filterbank.h" #include "audio/dsp/spectrogram/spectrogram.h" -#include "feature_extractor_interface.h" +#include "lyra/feature_extractor_interface.h" namespace chromemedia { namespace codec { @@ -77,4 +77,4 @@ class LogMelSpectrogramExtractorImpl : public FeatureExtractorInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_LOG_MEL_SPECTROGRAM_EXTRACTOR_IMPL_H_ +#endif // LYRA_LOG_MEL_SPECTROGRAM_EXTRACTOR_IMPL_H_ diff --git a/log_mel_spectrogram_extractor_impl_benchmark.cc b/lyra/log_mel_spectrogram_extractor_impl_benchmark.cc similarity index 97% rename from log_mel_spectrogram_extractor_impl_benchmark.cc rename to lyra/log_mel_spectrogram_extractor_impl_benchmark.cc index f286ac18..e3ea8f59 100644 --- a/log_mel_spectrogram_extractor_impl_benchmark.cc +++ b/lyra/log_mel_spectrogram_extractor_impl_benchmark.cc @@ -19,7 +19,7 @@ #include "absl/random/random.h" #include "absl/types/span.h" #include "benchmark/benchmark.h" -#include "log_mel_spectrogram_extractor_impl.h" +#include "lyra/log_mel_spectrogram_extractor_impl.h" static constexpr int kTestSampleRateHz = 16000; static constexpr int kNumMelBins = 10; diff --git a/log_mel_spectrogram_extractor_impl_test.cc b/lyra/log_mel_spectrogram_extractor_impl_test.cc similarity index 98% rename from log_mel_spectrogram_extractor_impl_test.cc rename to lyra/log_mel_spectrogram_extractor_impl_test.cc index 6d99e499..b366b917 100644 --- a/log_mel_spectrogram_extractor_impl_test.cc +++ b/lyra/log_mel_spectrogram_extractor_impl_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "log_mel_spectrogram_extractor_impl.h" +#include "lyra/log_mel_spectrogram_extractor_impl.h" #include #include diff --git a/lyra_benchmark.cc b/lyra/lyra_benchmark.cc similarity index 89% rename from lyra_benchmark.cc rename to lyra/lyra_benchmark.cc index 219fb66e..4f5b19ab 100644 --- a/lyra_benchmark.cc +++ b/lyra/lyra_benchmark.cc @@ -18,19 +18,18 @@ #include "absl/flags/parse.h" #include "absl/flags/usage.h" #include "absl/strings/string_view.h" -#include "lyra_benchmark_lib.h" +#include "lyra/lyra_benchmark_lib.h" ABSL_FLAG(int, num_cond_vectors, 2000, "The number of conditioning vectors to feed to the conditioning " "stack / network. " "Equivalent to the number of calls to Precompute and Run."); -ABSL_FLAG(std::string, model_path, "model_coeffs", +ABSL_FLAG(std::string, model_path, "lyra/model_coeffs", "Path to directory containing TFLite files. For mobile this is the " "absolute path, like " - "'/data/local/tmp/model_coeffs/'. For " - "desktop " - "this is the path relative to the binary."); + "'/data/local/tmp/lyra/model_coeffs/'." + " For desktop this is the path relative to the binary."); ABSL_FLAG(bool, benchmark_feature_extraction, true, "Whether to benchmark the feature extraction."); diff --git a/lyra_benchmark_lib.cc b/lyra/lyra_benchmark_lib.cc similarity index 97% rename from lyra_benchmark_lib.cc rename to lyra/lyra_benchmark_lib.cc index 5e217757..5d6fc994 100644 --- a/lyra_benchmark_lib.cc +++ b/lyra/lyra_benchmark_lib.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "lyra_benchmark_lib.h" +#include "lyra/lyra_benchmark_lib.h" #include #include @@ -36,15 +36,15 @@ #include "absl/strings/string_view.h" #include "absl/strings/substitute.h" #include "absl/types/span.h" -#include "architecture_utils.h" #include "audio/dsp/signal_vector_util.h" -#include "dsp_utils.h" -#include "feature_extractor_interface.h" -#include "generative_model_interface.h" #include "glog/logging.h" // IWYU pragma: keep #include "include/ghc/filesystem.hpp" -#include "lyra_components.h" -#include "lyra_config.h" +#include "lyra/architecture_utils.h" +#include "lyra/dsp_utils.h" +#include "lyra/feature_extractor_interface.h" +#include "lyra/generative_model_interface.h" +#include "lyra/lyra_components.h" +#include "lyra/lyra_config.h" #ifdef BENCHMARK #include "absl/base/thread_annotations.h" diff --git a/lyra_benchmark_lib.h b/lyra/lyra_benchmark_lib.h similarity index 89% rename from lyra_benchmark_lib.h rename to lyra/lyra_benchmark_lib.h index 527746b5..0b843344 100644 --- a/lyra_benchmark_lib.h +++ b/lyra/lyra_benchmark_lib.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_LYRA_BENCHMARK_LIB_H_ -#define LYRA_CODEC_LYRA_BENCHMARK_LIB_H_ +#ifndef LYRA_LYRA_BENCHMARK_LIB_H_ +#define LYRA_LYRA_BENCHMARK_LIB_H_ #include #include @@ -38,4 +38,4 @@ int lyra_benchmark(int num_cond_vectors, const std::string& model_base_path, } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_LYRA_BENCHMARK_LIB_H_ +#endif // LYRA_LYRA_BENCHMARK_LIB_H_ diff --git a/lyra_components.cc b/lyra/lyra_components.cc similarity index 82% rename from lyra_components.cc rename to lyra/lyra_components.cc index ba3361ee..ed35b65a 100644 --- a/lyra_components.cc +++ b/lyra/lyra_components.cc @@ -12,19 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "lyra_components.h" +#include "lyra/lyra_components.h" #include -#include "feature_extractor_interface.h" -#include "generative_model_interface.h" -#include "lyra_gan_model.h" -#include "packet.h" -#include "packet_interface.h" -#include "residual_vector_quantizer.h" -#include "soundstream_encoder.h" -#include "vector_quantizer_interface.h" -#include "zero_feature_estimator.h" +#include "lyra/feature_extractor_interface.h" +#include "lyra/generative_model_interface.h" +#include "lyra/lyra_gan_model.h" +#include "lyra/packet.h" +#include "lyra/packet_interface.h" +#include "lyra/residual_vector_quantizer.h" +#include "lyra/soundstream_encoder.h" +#include "lyra/vector_quantizer_interface.h" +#include "lyra/zero_feature_estimator.h" namespace chromemedia { namespace codec { diff --git a/lyra_components.h b/lyra/lyra_components.h similarity index 80% rename from lyra_components.h rename to lyra/lyra_components.h index 5277258a..54ef2ea4 100644 --- a/lyra_components.h +++ b/lyra/lyra_components.h @@ -14,17 +14,17 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_LYRA_COMPONENTS_H_ -#define LYRA_CODEC_LYRA_COMPONENTS_H_ +#ifndef LYRA_LYRA_COMPONENTS_H_ +#define LYRA_LYRA_COMPONENTS_H_ #include -#include "feature_estimator_interface.h" -#include "feature_extractor_interface.h" -#include "generative_model_interface.h" #include "include/ghc/filesystem.hpp" -#include "packet_interface.h" -#include "vector_quantizer_interface.h" +#include "lyra/feature_estimator_interface.h" +#include "lyra/feature_extractor_interface.h" +#include "lyra/generative_model_interface.h" +#include "lyra/packet_interface.h" +#include "lyra/vector_quantizer_interface.h" namespace chromemedia { namespace codec { @@ -47,4 +47,4 @@ std::unique_ptr CreateFeatureEstimator( } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_LYRA_COMPONENTS_H_ +#endif // LYRA_LYRA_COMPONENTS_H_ diff --git a/lyra_config.cc b/lyra/lyra_config.cc similarity index 97% rename from lyra_config.cc rename to lyra/lyra_config.cc index 5bfba0ad..effdb15e 100644 --- a/lyra_config.cc +++ b/lyra/lyra_config.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "lyra_config.h" +#include "lyra/lyra_config.h" #include @@ -31,7 +31,7 @@ const int kVersionMajor = 1; // |identifier| field needs to be set in lyra_config.textproto to match this. const int kVersionMinor = 3; // The micro version is for other things like a release of bugfixes. -const int kVersionMicro = 0; +const int kVersionMicro = 1; const int kNumFeatures = 64; const int kNumMelBins = 160; diff --git a/lyra_config.h b/lyra/lyra_config.h similarity index 96% rename from lyra_config.h rename to lyra/lyra_config.h index b368381d..955787a6 100644 --- a/lyra_config.h +++ b/lyra/lyra_config.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_LYRA_CONFIG_H_ -#define LYRA_CODEC_LYRA_CONFIG_H_ +#ifndef LYRA_LYRA_CONFIG_H_ +#define LYRA_LYRA_CONFIG_H_ #include #include @@ -32,7 +32,7 @@ #include "absl/strings/string_view.h" #include "glog/logging.h" // IWYU pragma: keep #include "include/ghc/filesystem.hpp" -#include "lyra_config.pb.h" +#include "lyra/lyra_config.pb.h" namespace chromemedia { namespace codec { @@ -151,7 +151,7 @@ inline absl::Status AreParamsSupported( absl::StrFormat("Error when probing for asset %s: %s", lyra_config_proto_path.string(), error.message())); } - third_party::lyra_codec::LyraConfig lyra_config; + third_party::lyra_codec::lyra::LyraConfig lyra_config; if (exists) { std::ifstream lyra_config_stream(lyra_config_proto_path.string()); if (!lyra_config.ParseFromIstream(&lyra_config_stream)) { @@ -170,4 +170,4 @@ inline absl::Status AreParamsSupported( } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_LYRA_CONFIG_H_ +#endif // LYRA_LYRA_CONFIG_H_ diff --git a/lyra_config.proto b/lyra/lyra_config.proto similarity index 95% rename from lyra_config.proto rename to lyra/lyra_config.proto index 86ffe2fb..2037d459 100644 --- a/lyra_config.proto +++ b/lyra/lyra_config.proto @@ -14,7 +14,7 @@ syntax = "proto2"; -package third_party.lyra_codec; +package third_party.lyra_codec.lyra; // Main message to check version, including weights and bitstream, // compatibility. diff --git a/lyra_config_test.cc b/lyra/lyra_config_test.cc similarity index 95% rename from lyra_config_test.cc rename to lyra/lyra_config_test.cc index f35abd24..036ba410 100644 --- a/lyra_config_test.cc +++ b/lyra/lyra_config_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "lyra_config.h" +#include "lyra/lyra_config.h" #include #include @@ -23,7 +23,7 @@ #include "absl/status/status.h" #include "gtest/gtest.h" #include "include/ghc/filesystem.hpp" -#include "lyra_config.pb.h" +#include "lyra/lyra_config.pb.h" namespace chromemedia { namespace codec { @@ -32,7 +32,8 @@ namespace { class LyraConfigTest : public testing::Test { protected: LyraConfigTest() - : source_model_path_(ghc::filesystem::current_path() / "model_coeffs") {} + : source_model_path_(ghc::filesystem::current_path() / + "lyra/model_coeffs") {} void SetUp() override { // Create a uniqe sub-directory so tests do not interfere with each other. @@ -141,7 +142,7 @@ TEST_F(LyraConfigTest, MismatchedIdentifierNotSupported) { const ghc::filesystem::path lyra_config_proto_path = test_model_path_ / "lyra_config.binarypb"; DeleteFile(lyra_config_proto_path); - third_party::lyra_codec::LyraConfig lyra_config_proto; + third_party::lyra_codec::lyra::LyraConfig lyra_config_proto; lyra_config_proto.set_identifier(kVersionMinor + 100); std::ofstream output_proto(lyra_config_proto_path.string(), std::ofstream::out | std::ofstream::binary); diff --git a/lyra_decoder.cc b/lyra/lyra_decoder.cc similarity index 98% rename from lyra_decoder.cc rename to lyra/lyra_decoder.cc index e7593329..73961b3b 100644 --- a/lyra_decoder.cc +++ b/lyra/lyra_decoder.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "lyra_decoder.h" +#include "lyra/lyra_decoder.h" #include #include @@ -26,13 +26,13 @@ #include "absl/memory/memory.h" #include "absl/status/status.h" #include "absl/types/span.h" -#include "buffered_resampler.h" -#include "comfort_noise_generator.h" #include "glog/logging.h" // IWYU pragma: keep #include "include/ghc/filesystem.hpp" -#include "lyra_components.h" -#include "lyra_config.h" -#include "noise_estimator.h" +#include "lyra/buffered_resampler.h" +#include "lyra/comfort_noise_generator.h" +#include "lyra/lyra_components.h" +#include "lyra/lyra_config.h" +#include "lyra/noise_estimator.h" namespace chromemedia { namespace codec { diff --git a/lyra_decoder.h b/lyra/lyra_decoder.h similarity index 94% rename from lyra_decoder.h rename to lyra/lyra_decoder.h index 90178646..72ee1e4c 100644 --- a/lyra_decoder.h +++ b/lyra/lyra_decoder.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_LYRA_DECODER_H_ -#define LYRA_CODEC_LYRA_DECODER_H_ +#ifndef LYRA_LYRA_DECODER_H_ +#define LYRA_LYRA_DECODER_H_ #include #include @@ -23,13 +23,13 @@ #include #include "absl/types/span.h" -#include "buffered_filter_interface.h" -#include "feature_estimator_interface.h" -#include "generative_model_interface.h" #include "include/ghc/filesystem.hpp" -#include "lyra_decoder_interface.h" -#include "noise_estimator_interface.h" -#include "vector_quantizer_interface.h" +#include "lyra/buffered_filter_interface.h" +#include "lyra/feature_estimator_interface.h" +#include "lyra/generative_model_interface.h" +#include "lyra/lyra_decoder_interface.h" +#include "lyra/noise_estimator_interface.h" +#include "lyra/vector_quantizer_interface.h" namespace chromemedia { namespace codec { @@ -165,4 +165,4 @@ class LyraDecoder : public LyraDecoderInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_LYRA_DECODER_H_ +#endif // LYRA_LYRA_DECODER_H_ diff --git a/lyra_decoder_interface.h b/lyra/lyra_decoder_interface.h similarity index 91% rename from lyra_decoder_interface.h rename to lyra/lyra_decoder_interface.h index e81aa459..8e393606 100644 --- a/lyra_decoder_interface.h +++ b/lyra/lyra_decoder_interface.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_LYRA_DECODER_INTERFACE_H_ -#define LYRA_CODEC_LYRA_DECODER_INTERFACE_H_ +#ifndef LYRA_LYRA_DECODER_INTERFACE_H_ +#define LYRA_LYRA_DECODER_INTERFACE_H_ #include #include @@ -54,4 +54,4 @@ class LyraDecoderInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_LYRA_DECODER_INTERFACE_H_ +#endif // LYRA_LYRA_DECODER_INTERFACE_H_ diff --git a/lyra_decoder_test.cc b/lyra/lyra_decoder_test.cc similarity index 98% rename from lyra_decoder_test.cc rename to lyra/lyra_decoder_test.cc index 27a1c07d..dba72772 100644 --- a/lyra_decoder_test.cc +++ b/lyra/lyra_decoder_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "lyra_decoder.h" +#include "lyra/lyra_decoder.h" #include #include @@ -27,22 +27,22 @@ // Placeholder for get runfiles header. #include "absl/strings/string_view.h" #include "absl/types/span.h" -#include "buffered_filter_interface.h" -#include "buffered_resampler.h" -#include "dsp_utils.h" -#include "feature_estimator_interface.h" -#include "generative_model_interface.h" #include "gmock/gmock.h" #include "gtest/gtest.h" #include "include/ghc/filesystem.hpp" -#include "lyra_components.h" -#include "lyra_config.h" -#include "packet_interface.h" -#include "resampler.h" -#include "testing/mock_generative_model.h" -#include "testing/mock_noise_estimator.h" -#include "testing/mock_vector_quantizer.h" -#include "vector_quantizer_interface.h" +#include "lyra/buffered_filter_interface.h" +#include "lyra/buffered_resampler.h" +#include "lyra/dsp_utils.h" +#include "lyra/feature_estimator_interface.h" +#include "lyra/generative_model_interface.h" +#include "lyra/lyra_components.h" +#include "lyra/lyra_config.h" +#include "lyra/packet_interface.h" +#include "lyra/resampler.h" +#include "lyra/testing/mock_generative_model.h" +#include "lyra/testing/mock_noise_estimator.h" +#include "lyra/testing/mock_vector_quantizer.h" +#include "lyra/vector_quantizer_interface.h" namespace chromemedia { namespace codec { @@ -95,7 +95,7 @@ namespace { using testing::Exactly; using testing::Return; -static constexpr absl::string_view kExportedModelPath = "model_coeffs"; +static constexpr absl::string_view kExportedModelPath = "lyra/model_coeffs"; // Duration of pure packet loss concealment. inline int GetConcealmentDurationSamples() { diff --git a/lyra_encoder.cc b/lyra/lyra_encoder.cc similarity index 93% rename from lyra_encoder.cc rename to lyra/lyra_encoder.cc index 573ebbe9..3d774c8b 100644 --- a/lyra_encoder.cc +++ b/lyra/lyra_encoder.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "lyra_encoder.h" +#include "lyra/lyra_encoder.h" #include #include @@ -24,18 +24,18 @@ #include "absl/memory/memory.h" #include "absl/status/status.h" #include "absl/types/span.h" -#include "feature_extractor_interface.h" #include "glog/logging.h" // IWYU pragma: keep #include "include/ghc/filesystem.hpp" -#include "lyra_components.h" -#include "lyra_config.h" -#include "noise_estimator.h" -#include "noise_estimator_interface.h" -#include "packet.h" -#include "packet_interface.h" -#include "resampler.h" -#include "resampler_interface.h" -#include "vector_quantizer_interface.h" +#include "lyra/feature_extractor_interface.h" +#include "lyra/lyra_components.h" +#include "lyra/lyra_config.h" +#include "lyra/noise_estimator.h" +#include "lyra/noise_estimator_interface.h" +#include "lyra/packet.h" +#include "lyra/packet_interface.h" +#include "lyra/resampler.h" +#include "lyra/resampler_interface.h" +#include "lyra/vector_quantizer_interface.h" namespace chromemedia { namespace codec { diff --git a/lyra_encoder.h b/lyra/lyra_encoder.h similarity index 86% rename from lyra_encoder.h rename to lyra/lyra_encoder.h index 07782b72..5aafd249 100644 --- a/lyra_encoder.h +++ b/lyra/lyra_encoder.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_LYRA_ENCODER_H_ -#define LYRA_CODEC_LYRA_ENCODER_H_ +#ifndef LYRA_LYRA_ENCODER_H_ +#define LYRA_LYRA_ENCODER_H_ #include #include @@ -23,12 +23,12 @@ #include #include "absl/types/span.h" -#include "feature_extractor_interface.h" #include "include/ghc/filesystem.hpp" -#include "lyra_encoder_interface.h" -#include "noise_estimator_interface.h" -#include "resampler_interface.h" -#include "vector_quantizer_interface.h" +#include "lyra/feature_extractor_interface.h" +#include "lyra/lyra_encoder_interface.h" +#include "lyra/noise_estimator_interface.h" +#include "lyra/resampler_interface.h" +#include "lyra/vector_quantizer_interface.h" namespace chromemedia { namespace codec { @@ -66,9 +66,11 @@ class LyraEncoder : public LyraEncoderInterface { /// /// @param audio Span of int16-formatted samples. It is assumed to contain /// 20ms of data at the sample rate chosen at Create time. - /// @return Encoded packet as a vector of bytes as long as the right amount of - /// data is provided. Else it returns nullopt. It also returns nullopt - /// if DTX is enabled and the packet is deemed to contain silence. + /// @return Encoded packet as a vector of bytes if the correct number of + /// of samples are provided, otherwise it returns nullopt. + /// The return vector will be of length zero if discontinuous + /// transmission mode is enabled and the frame contains + /// background noise. std::optional> Encode( const absl::Span audio) override; @@ -122,4 +124,4 @@ class LyraEncoder : public LyraEncoderInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_LYRA_ENCODER_H_ +#endif // LYRA_LYRA_ENCODER_H_ diff --git a/lyra_encoder_interface.h b/lyra/lyra_encoder_interface.h similarity index 90% rename from lyra_encoder_interface.h rename to lyra/lyra_encoder_interface.h index 083720c3..978f3a59 100644 --- a/lyra_encoder_interface.h +++ b/lyra/lyra_encoder_interface.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_LYRA_ENCODER_INTERFACE_H_ -#define LYRA_CODEC_LYRA_ENCODER_INTERFACE_H_ +#ifndef LYRA_LYRA_ENCODER_INTERFACE_H_ +#define LYRA_LYRA_ENCODER_INTERFACE_H_ #include #include @@ -50,4 +50,4 @@ class LyraEncoderInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_LYRA_ENCODER_INTERFACE_H_ +#endif // LYRA_LYRA_ENCODER_INTERFACE_H_ diff --git a/lyra_encoder_test.cc b/lyra/lyra_encoder_test.cc similarity index 96% rename from lyra_encoder_test.cc rename to lyra/lyra_encoder_test.cc index a91969d5..384c59e4 100644 --- a/lyra_encoder_test.cc +++ b/lyra/lyra_encoder_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "lyra_encoder.h" +#include "lyra/lyra_encoder.h" #include #include @@ -27,19 +27,19 @@ // Placeholder for get runfiles header. #include "absl/types/span.h" -#include "feature_extractor_interface.h" #include "gmock/gmock.h" #include "gtest/gtest.h" #include "include/ghc/filesystem.hpp" -#include "lyra_config.h" -#include "noise_estimator_interface.h" -#include "packet.h" -#include "resampler_interface.h" -#include "testing/mock_feature_extractor.h" -#include "testing/mock_noise_estimator.h" -#include "testing/mock_resampler.h" -#include "testing/mock_vector_quantizer.h" -#include "vector_quantizer_interface.h" +#include "lyra/feature_extractor_interface.h" +#include "lyra/lyra_config.h" +#include "lyra/noise_estimator_interface.h" +#include "lyra/packet.h" +#include "lyra/resampler_interface.h" +#include "lyra/testing/mock_feature_extractor.h" +#include "lyra/testing/mock_noise_estimator.h" +#include "lyra/testing/mock_resampler.h" +#include "lyra/testing/mock_vector_quantizer.h" +#include "lyra/vector_quantizer_interface.h" namespace chromemedia { namespace codec { @@ -303,7 +303,7 @@ TEST_P(LyraEncoderTest, MultipleEncodeCalls) { TEST_P(LyraEncoderTest, GoodCreationParametersReturnNotNullptr) { const auto valid_model_path = - ghc::filesystem::current_path() / "model_coeffs"; + ghc::filesystem::current_path() / "lyra/model_coeffs"; EXPECT_NE(nullptr, LyraEncoder::Create(external_sample_rate_hz_, kNumChannels, @@ -317,7 +317,7 @@ TEST_P(LyraEncoderTest, GoodCreationParametersReturnNotNullptr) { TEST_P(LyraEncoderTest, BadCreationParametersReturnNullptr) { const auto valid_model_path = - ghc::filesystem::current_path() / "model_coeffs"; + ghc::filesystem::current_path() / "lyra/model_coeffs"; EXPECT_EQ(nullptr, LyraEncoder::Create( 0, kNumChannels, GetBitrate(num_quantized_bits_), diff --git a/lyra_gan_model.cc b/lyra/lyra_gan_model.cc similarity index 95% rename from lyra_gan_model.cc rename to lyra/lyra_gan_model.cc index 1f573516..13d6462a 100644 --- a/lyra_gan_model.cc +++ b/lyra/lyra_gan_model.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "lyra_gan_model.h" +#include "lyra/lyra_gan_model.h" #include #include @@ -26,9 +26,9 @@ #include "absl/memory/memory.h" #include "absl/types/span.h" -#include "dsp_utils.h" #include "glog/logging.h" // IWYU pragma: keep -#include "tflite_model_wrapper.h" +#include "lyra/dsp_utils.h" +#include "lyra/tflite_model_wrapper.h" namespace chromemedia { namespace codec { diff --git a/lyra_gan_model.h b/lyra/lyra_gan_model.h similarity index 86% rename from lyra_gan_model.h rename to lyra/lyra_gan_model.h index 92fdd0a1..38c92524 100644 --- a/lyra_gan_model.h +++ b/lyra/lyra_gan_model.h @@ -14,17 +14,17 @@ * limitations under the License. */ -#ifndef THIRD_PARTY_LYRA_CODEC_LYRA_GAN_MODEL_H_ -#define THIRD_PARTY_LYRA_CODEC_LYRA_GAN_MODEL_H_ +#ifndef LYRA_LYRA_GAN_MODEL_H_ +#define LYRA_LYRA_GAN_MODEL_H_ #include #include #include #include -#include "generative_model_interface.h" #include "include/ghc/filesystem.hpp" -#include "tflite_model_wrapper.h" +#include "lyra/generative_model_interface.h" +#include "lyra/tflite_model_wrapper.h" namespace chromemedia { namespace codec { @@ -52,4 +52,4 @@ class LyraGanModel : public GenerativeModel { } // namespace codec } // namespace chromemedia -#endif // THIRD_PARTY_LYRA_CODEC_LYRA_GAN_MODEL_H_ +#endif // LYRA_LYRA_GAN_MODEL_H_ diff --git a/lyra_gan_model_test.cc b/lyra/lyra_gan_model_test.cc similarity index 93% rename from lyra_gan_model_test.cc rename to lyra/lyra_gan_model_test.cc index 77c35321..25ffcdd8 100644 --- a/lyra_gan_model_test.cc +++ b/lyra/lyra_gan_model_test.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "lyra_gan_model.h" +#include "lyra/lyra_gan_model.h" #include #include @@ -24,7 +24,7 @@ // Placeholder for get runfiles header. #include "gtest/gtest.h" #include "include/ghc/filesystem.hpp" -#include "lyra_config.h" +#include "lyra/lyra_config.h" namespace chromemedia { namespace codec { @@ -34,7 +34,8 @@ class LyraGanModelTest : public testing::Test { protected: LyraGanModelTest() : model_(LyraGanModel::Create( - ghc::filesystem::current_path() / "model_coeffs", kNumFeatures)), + ghc::filesystem::current_path() / "lyra/model_coeffs", + kNumFeatures)), features_(kNumFeatures) {} void ExpectValidSampleGeneration(int num_samples) { diff --git a/lyra_integration_test.cc b/lyra/lyra_integration_test.cc similarity index 94% rename from lyra_integration_test.cc rename to lyra/lyra_integration_test.cc index 7685ff1c..bad59c18 100644 --- a/lyra_integration_test.cc +++ b/lyra/lyra_integration_test.cc @@ -24,15 +24,15 @@ #include "absl/status/statusor.h" #include "absl/strings/string_view.h" #include "absl/types/span.h" -#include "dsp_utils.h" #include "gmock/gmock.h" #include "gtest/gtest.h" #include "include/ghc/filesystem.hpp" -#include "log_mel_spectrogram_extractor_impl.h" -#include "lyra_config.h" -#include "lyra_decoder.h" -#include "lyra_encoder.h" -#include "wav_utils.h" +#include "lyra/dsp_utils.h" +#include "lyra/log_mel_spectrogram_extractor_impl.h" +#include "lyra/lyra_config.h" +#include "lyra/lyra_decoder.h" +#include "lyra/lyra_encoder.h" +#include "lyra/wav_utils.h" namespace chromemedia { namespace codec { @@ -47,9 +47,9 @@ class LyraIntegrationTest // This tests that decoded audio has similar features as the original. TEST_P(LyraIntegrationTest, DecodedAudioHasSimilarFeatures) { - const ghc::filesystem::path wav_dir("testdata"); + const ghc::filesystem::path wav_dir("lyra/testdata"); const auto model_path = - ghc::filesystem::current_path() / std::string("model_coeffs"); + ghc::filesystem::current_path() / std::string("lyra/model_coeffs"); const auto input_path = ghc::filesystem::current_path() / wav_dir / std::string(std::get<0>(GetParam())); diff --git a/model_coeffs/lyra_config.binarypb b/lyra/model_coeffs/lyra_config.binarypb similarity index 100% rename from model_coeffs/lyra_config.binarypb rename to lyra/model_coeffs/lyra_config.binarypb diff --git a/model_coeffs/lyragan.tflite b/lyra/model_coeffs/lyragan.tflite similarity index 100% rename from model_coeffs/lyragan.tflite rename to lyra/model_coeffs/lyragan.tflite diff --git a/model_coeffs/quantizer.tflite b/lyra/model_coeffs/quantizer.tflite similarity index 100% rename from model_coeffs/quantizer.tflite rename to lyra/model_coeffs/quantizer.tflite diff --git a/model_coeffs/soundstream_encoder.tflite b/lyra/model_coeffs/soundstream_encoder.tflite similarity index 100% rename from model_coeffs/soundstream_encoder.tflite rename to lyra/model_coeffs/soundstream_encoder.tflite diff --git a/model_coeffs/test_playback.wav b/lyra/model_coeffs/test_playback.wav similarity index 100% rename from model_coeffs/test_playback.wav rename to lyra/model_coeffs/test_playback.wav diff --git a/no_op_preprocessor.h b/lyra/no_op_preprocessor.h similarity index 87% rename from no_op_preprocessor.h rename to lyra/no_op_preprocessor.h index 5001753c..d22a7709 100644 --- a/no_op_preprocessor.h +++ b/lyra/no_op_preprocessor.h @@ -14,14 +14,14 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_NO_OP_PREPROCESSOR_H_ -#define LYRA_CODEC_NO_OP_PREPROCESSOR_H_ +#ifndef LYRA_NO_OP_PREPROCESSOR_H_ +#define LYRA_NO_OP_PREPROCESSOR_H_ #include #include #include "absl/types/span.h" -#include "preprocessor_interface.h" +#include "lyra/preprocessor_interface.h" namespace chromemedia { namespace codec { @@ -39,4 +39,4 @@ class NoOpPreprocessor : public PreprocessorInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_NO_OP_PREPROCESSOR_H_ +#endif // LYRA_NO_OP_PREPROCESSOR_H_ diff --git a/no_op_preprocessor_test.cc b/lyra/no_op_preprocessor_test.cc similarity index 97% rename from no_op_preprocessor_test.cc rename to lyra/no_op_preprocessor_test.cc index 52fa5fa6..0e641e92 100644 --- a/no_op_preprocessor_test.cc +++ b/lyra/no_op_preprocessor_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "no_op_preprocessor.h" +#include "lyra/no_op_preprocessor.h" #include #include diff --git a/noise_estimator.cc b/lyra/noise_estimator.cc similarity index 99% rename from noise_estimator.cc rename to lyra/noise_estimator.cc index 11f5eac9..58b06f19 100644 --- a/noise_estimator.cc +++ b/lyra/noise_estimator.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "noise_estimator.h" +#include "lyra/noise_estimator.h" #include #include @@ -27,7 +27,7 @@ #include "absl/types/span.h" #include "audio/dsp/signal_vector_util.h" #include "glog/logging.h" // IWYU pragma: keep -#include "log_mel_spectrogram_extractor_impl.h" +#include "lyra/log_mel_spectrogram_extractor_impl.h" namespace chromemedia { namespace codec { diff --git a/noise_estimator.h b/lyra/noise_estimator.h similarity index 94% rename from noise_estimator.h rename to lyra/noise_estimator.h index d0a55433..b1ec2712 100644 --- a/noise_estimator.h +++ b/lyra/noise_estimator.h @@ -14,16 +14,16 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_NOISE_ESTIMATOR_H_ -#define LYRA_CODEC_NOISE_ESTIMATOR_H_ +#ifndef LYRA_NOISE_ESTIMATOR_H_ +#define LYRA_NOISE_ESTIMATOR_H_ #include #include #include #include "absl/types/span.h" -#include "log_mel_spectrogram_extractor_impl.h" -#include "noise_estimator_interface.h" +#include "lyra/log_mel_spectrogram_extractor_impl.h" +#include "lyra/noise_estimator_interface.h" namespace chromemedia { namespace codec { @@ -99,4 +99,4 @@ class NoiseEstimator : public NoiseEstimatorInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_NOISE_ESTIMATOR_H_ +#endif // LYRA_NOISE_ESTIMATOR_H_ diff --git a/noise_estimator_interface.h b/lyra/noise_estimator_interface.h similarity index 88% rename from noise_estimator_interface.h rename to lyra/noise_estimator_interface.h index 961d6df5..91de39d8 100644 --- a/noise_estimator_interface.h +++ b/lyra/noise_estimator_interface.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_NOISE_ESTIMATOR_INTERFACE_H_ -#define LYRA_CODEC_NOISE_ESTIMATOR_INTERFACE_H_ +#ifndef LYRA_NOISE_ESTIMATOR_INTERFACE_H_ +#define LYRA_NOISE_ESTIMATOR_INTERFACE_H_ #include #include @@ -40,4 +40,4 @@ class NoiseEstimatorInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_NOISE_ESTIMATOR_INTERFACE_H_ +#endif // LYRA_NOISE_ESTIMATOR_INTERFACE_H_ diff --git a/noise_estimator_test.cc b/lyra/noise_estimator_test.cc similarity index 97% rename from noise_estimator_test.cc rename to lyra/noise_estimator_test.cc index 17472367..e54878eb 100644 --- a/noise_estimator_test.cc +++ b/lyra/noise_estimator_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "noise_estimator.h" +#include "lyra/noise_estimator.h" #include #include @@ -23,11 +23,11 @@ #include #include -#include "comfort_noise_generator.h" -#include "dsp_utils.h" #include "gtest/gtest.h" -#include "log_mel_spectrogram_extractor_impl.h" -#include "lyra_config.h" +#include "lyra/comfort_noise_generator.h" +#include "lyra/dsp_utils.h" +#include "lyra/log_mel_spectrogram_extractor_impl.h" +#include "lyra/lyra_config.h" namespace chromemedia { namespace codec { diff --git a/packet.h b/lyra/packet.h similarity index 98% rename from packet.h rename to lyra/packet.h index a705ba4d..6bfa4c6c 100644 --- a/packet.h +++ b/lyra/packet.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_PACKET_H_ -#define LYRA_CODEC_PACKET_H_ +#ifndef LYRA_PACKET_H_ +#define LYRA_PACKET_H_ #include #include @@ -29,7 +29,7 @@ #include "absl/memory/memory.h" #include "absl/types/span.h" #include "glog/logging.h" // IWYU pragma: keep -#include "packet_interface.h" +#include "lyra/packet_interface.h" namespace chromemedia { namespace codec { @@ -174,4 +174,4 @@ class Packet : public PacketInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_PACKET_H_ +#endif // LYRA_PACKET_H_ diff --git a/packet_interface.h b/lyra/packet_interface.h similarity index 91% rename from packet_interface.h rename to lyra/packet_interface.h index e1c4545d..67406a3e 100644 --- a/packet_interface.h +++ b/lyra/packet_interface.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_PACKET_INTERFACE_H_ -#define LYRA_CODEC_PACKET_INTERFACE_H_ +#ifndef LYRA_PACKET_INTERFACE_H_ +#define LYRA_PACKET_INTERFACE_H_ #include #include @@ -47,4 +47,4 @@ class PacketInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_PACKET_INTERFACE_H_ +#endif // LYRA_PACKET_INTERFACE_H_ diff --git a/packet_loss_model_interface.h b/lyra/packet_loss_model_interface.h similarity index 81% rename from packet_loss_model_interface.h rename to lyra/packet_loss_model_interface.h index 22edbe68..46c88e24 100644 --- a/packet_loss_model_interface.h +++ b/lyra/packet_loss_model_interface.h @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef THIRD_PARTY_LYRA_CODEC_PACKET_LOSS_MODEL_INTERFACE_H_ -#define THIRD_PARTY_LYRA_CODEC_PACKET_LOSS_MODEL_INTERFACE_H_ +#ifndef LYRA_PACKET_LOSS_MODEL_INTERFACE_H_ +#define LYRA_PACKET_LOSS_MODEL_INTERFACE_H_ namespace chromemedia { namespace codec { @@ -30,4 +30,4 @@ class PacketLossModelInterface { } // namespace codec } // namespace chromemedia -#endif // THIRD_PARTY_LYRA_CODEC_PACKET_LOSS_MODEL_INTERFACE_H_ +#endif // LYRA_PACKET_LOSS_MODEL_INTERFACE_H_ diff --git a/packet_test.cc b/lyra/packet_test.cc similarity index 99% rename from packet_test.cc rename to lyra/packet_test.cc index ff426833..81651095 100644 --- a/packet_test.cc +++ b/lyra/packet_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "packet.h" +#include "lyra/packet.h" #include #include diff --git a/preprocessor_interface.h b/lyra/preprocessor_interface.h similarity index 88% rename from preprocessor_interface.h rename to lyra/preprocessor_interface.h index 7ffac5d2..8b8581cd 100644 --- a/preprocessor_interface.h +++ b/lyra/preprocessor_interface.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_PREPROCESSOR_INTERFACE_H_ -#define LYRA_CODEC_PREPROCESSOR_INTERFACE_H_ +#ifndef LYRA_PREPROCESSOR_INTERFACE_H_ +#define LYRA_PREPROCESSOR_INTERFACE_H_ #include #include @@ -38,4 +38,4 @@ class PreprocessorInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_PREPROCESSOR_INTERFACE_H_ +#endif // LYRA_PREPROCESSOR_INTERFACE_H_ diff --git a/resampler.cc b/lyra/resampler.cc similarity index 98% rename from resampler.cc rename to lyra/resampler.cc index d600b3c7..2fa6b12a 100644 --- a/resampler.cc +++ b/lyra/resampler.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "resampler.h" +#include "lyra/resampler.h" #include #include @@ -23,8 +23,8 @@ #include "absl/memory/memory.h" #include "absl/types/span.h" #include "audio/dsp/resampler_q.h" -#include "dsp_utils.h" #include "glog/logging.h" // IWYU pragma: keep +#include "lyra/dsp_utils.h" namespace chromemedia { namespace codec { diff --git a/resampler.h b/lyra/resampler.h similarity index 92% rename from resampler.h rename to lyra/resampler.h index 19cf4909..83ed4657 100644 --- a/resampler.h +++ b/lyra/resampler.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_RESAMPLER_H_ -#define LYRA_CODEC_RESAMPLER_H_ +#ifndef LYRA_RESAMPLER_H_ +#define LYRA_RESAMPLER_H_ #include #include @@ -23,7 +23,7 @@ #include "absl/types/span.h" #include "audio/dsp/resampler_q.h" -#include "resampler_interface.h" +#include "lyra/resampler_interface.h" namespace chromemedia { namespace codec { @@ -58,4 +58,4 @@ class Resampler : public ResamplerInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_RESAMPLER_H_ +#endif // LYRA_RESAMPLER_H_ diff --git a/resampler_interface.h b/lyra/resampler_interface.h similarity index 89% rename from resampler_interface.h rename to lyra/resampler_interface.h index 72bfa537..8ae6e718 100644 --- a/resampler_interface.h +++ b/lyra/resampler_interface.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_RESAMPLER_INTERFACE_H_ -#define LYRA_CODEC_RESAMPLER_INTERFACE_H_ +#ifndef LYRA_RESAMPLER_INTERFACE_H_ +#define LYRA_RESAMPLER_INTERFACE_H_ #include #include @@ -43,4 +43,4 @@ class ResamplerInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_RESAMPLER_INTERFACE_H_ +#endif // LYRA_RESAMPLER_INTERFACE_H_ diff --git a/resampler_test.cc b/lyra/resampler_test.cc similarity index 98% rename from resampler_test.cc rename to lyra/resampler_test.cc index cdd9c83c..1551c82b 100644 --- a/resampler_test.cc +++ b/lyra/resampler_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "resampler.h" +#include "lyra/resampler.h" #include #include @@ -23,7 +23,7 @@ #include "absl/types/span.h" #include "audio/dsp/signal_vector_util.h" #include "gtest/gtest.h" -#include "lyra_config.h" +#include "lyra/lyra_config.h" namespace chromemedia { namespace codec { diff --git a/residual_vector_quantizer.cc b/lyra/residual_vector_quantizer.cc similarity index 98% rename from residual_vector_quantizer.cc rename to lyra/residual_vector_quantizer.cc index 75bcff81..94041db7 100644 --- a/residual_vector_quantizer.cc +++ b/lyra/residual_vector_quantizer.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "residual_vector_quantizer.h" +#include "lyra/residual_vector_quantizer.h" #include #include @@ -28,7 +28,7 @@ #include "absl/memory/memory.h" #include "glog/logging.h" // IWYU pragma: keep #include "include/ghc/filesystem.hpp" -#include "tflite_model_wrapper.h" +#include "lyra/tflite_model_wrapper.h" namespace chromemedia { namespace codec { diff --git a/residual_vector_quantizer.h b/lyra/residual_vector_quantizer.h similarity index 88% rename from residual_vector_quantizer.h rename to lyra/residual_vector_quantizer.h index 32649396..66fe6886 100644 --- a/residual_vector_quantizer.h +++ b/lyra/residual_vector_quantizer.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef THIRD_PARTY_LYRA_CODEC_RESIDUAL_VECTOR_QUANTIZER_H_ -#define THIRD_PARTY_LYRA_CODEC_RESIDUAL_VECTOR_QUANTIZER_H_ +#ifndef LYRA_RESIDUAL_VECTOR_QUANTIZER_H_ +#define LYRA_RESIDUAL_VECTOR_QUANTIZER_H_ #include #include @@ -23,8 +23,8 @@ #include #include "include/ghc/filesystem.hpp" -#include "tflite_model_wrapper.h" -#include "vector_quantizer_interface.h" +#include "lyra/tflite_model_wrapper.h" +#include "lyra/vector_quantizer_interface.h" namespace chromemedia { namespace codec { @@ -65,4 +65,4 @@ class ResidualVectorQuantizer : public VectorQuantizerInterface { } // namespace codec } // namespace chromemedia -#endif // THIRD_PARTY_LYRA_CODEC_RESIDUAL_VECTOR_QUANTIZER_H_ +#endif // LYRA_RESIDUAL_VECTOR_QUANTIZER_H_ diff --git a/residual_vector_quantizer_test.cc b/lyra/residual_vector_quantizer_test.cc similarity index 95% rename from residual_vector_quantizer_test.cc rename to lyra/residual_vector_quantizer_test.cc index a897dcf0..d420ce94 100644 --- a/residual_vector_quantizer_test.cc +++ b/lyra/residual_vector_quantizer_test.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "residual_vector_quantizer.h" +#include "lyra/residual_vector_quantizer.h" #include #include @@ -25,8 +25,8 @@ // Placeholder for get runfiles header. #include "gtest/gtest.h" #include "include/ghc/filesystem.hpp" -#include "log_mel_spectrogram_extractor_impl.h" -#include "lyra_config.h" +#include "lyra/log_mel_spectrogram_extractor_impl.h" +#include "lyra/lyra_config.h" namespace chromemedia { namespace codec { @@ -37,7 +37,7 @@ class ResidualVectorQuantizerTest : public testing::TestWithParam { ResidualVectorQuantizerTest() : num_quantized_bits_(GetParam()), quantizer_(ResidualVectorQuantizer::Create( - ghc::filesystem::current_path() / "model_coeffs")), + ghc::filesystem::current_path() / "lyra/model_coeffs")), // These features correspond to silence run through the // SoundStreamEncoder using the SoundStreamEncoderTest. features_{ diff --git a/soundstream_encoder.cc b/lyra/soundstream_encoder.cc similarity index 95% rename from soundstream_encoder.cc rename to lyra/soundstream_encoder.cc index c0a0de61..5c5c32c3 100644 --- a/soundstream_encoder.cc +++ b/lyra/soundstream_encoder.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "soundstream_encoder.h" +#include "lyra/soundstream_encoder.h" #include #include @@ -25,10 +25,10 @@ #include "absl/memory/memory.h" #include "absl/types/span.h" -#include "dsp_utils.h" #include "glog/logging.h" // IWYU pragma: keep #include "include/ghc/filesystem.hpp" -#include "tflite_model_wrapper.h" +#include "lyra/dsp_utils.h" +#include "lyra/tflite_model_wrapper.h" namespace chromemedia { namespace codec { diff --git a/soundstream_encoder.h b/lyra/soundstream_encoder.h similarity index 86% rename from soundstream_encoder.h rename to lyra/soundstream_encoder.h index 55cc7203..f44d6e93 100644 --- a/soundstream_encoder.h +++ b/lyra/soundstream_encoder.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef THIRD_PARTY_LYRA_CODEC_SOUNDSTREAM_ENCODER_H_ -#define THIRD_PARTY_LYRA_CODEC_SOUNDSTREAM_ENCODER_H_ +#ifndef LYRA_SOUNDSTREAM_ENCODER_H_ +#define LYRA_SOUNDSTREAM_ENCODER_H_ #include #include @@ -23,9 +23,9 @@ #include #include "absl/types/span.h" -#include "feature_extractor_interface.h" #include "include/ghc/filesystem.hpp" -#include "tflite_model_wrapper.h" +#include "lyra/feature_extractor_interface.h" +#include "lyra/tflite_model_wrapper.h" namespace chromemedia { namespace codec { @@ -54,4 +54,4 @@ class SoundStreamEncoder : public FeatureExtractorInterface { } // namespace codec } // namespace chromemedia -#endif // THIRD_PARTY_LYRA_CODEC_SOUNDSTREAM_ENCODER_H_ +#endif // LYRA_SOUNDSTREAM_ENCODER_H_ diff --git a/soundstream_encoder_test.cc b/lyra/soundstream_encoder_test.cc similarity index 92% rename from soundstream_encoder_test.cc rename to lyra/soundstream_encoder_test.cc index 0a0a60f7..40f90e4d 100644 --- a/soundstream_encoder_test.cc +++ b/lyra/soundstream_encoder_test.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "soundstream_encoder.h" +#include "lyra/soundstream_encoder.h" #include #include @@ -25,7 +25,7 @@ // Placeholder for get runfiles header. #include "gtest/gtest.h" #include "include/ghc/filesystem.hpp" -#include "lyra_config.h" +#include "lyra/lyra_config.h" namespace chromemedia { namespace codec { @@ -35,7 +35,7 @@ class SoundStreamEncoderTest : public testing::Test { protected: SoundStreamEncoderTest() : encoder_(SoundStreamEncoder::Create(ghc::filesystem::current_path() / - "model_coeffs")) {} + "lyra/model_coeffs")) {} std::unique_ptr encoder_; }; diff --git a/testdata/BUILD b/lyra/testdata/BUILD similarity index 94% rename from testdata/BUILD rename to lyra/testdata/BUILD index f084ddc5..23ee36b3 100644 --- a/testdata/BUILD +++ b/lyra/testdata/BUILD @@ -1,4 +1,4 @@ -package(default_visibility = ["//:__pkg__"]) +package(default_visibility = ["//:__subpackages__"]) licenses(["notice"]) diff --git a/testdata/incomplete_encoded_packet.lyra b/lyra/testdata/incomplete_encoded_packet.lyra similarity index 100% rename from testdata/incomplete_encoded_packet.lyra rename to lyra/testdata/incomplete_encoded_packet.lyra diff --git a/testdata/invalid.wav b/lyra/testdata/invalid.wav similarity index 100% rename from testdata/invalid.wav rename to lyra/testdata/invalid.wav diff --git a/testdata/no_encoded_packet.lyra b/lyra/testdata/no_encoded_packet.lyra similarity index 100% rename from testdata/no_encoded_packet.lyra rename to lyra/testdata/no_encoded_packet.lyra diff --git a/testdata/one_encoded_packet_16khz.lyra b/lyra/testdata/one_encoded_packet_16khz.lyra similarity index 100% rename from testdata/one_encoded_packet_16khz.lyra rename to lyra/testdata/one_encoded_packet_16khz.lyra diff --git a/testdata/sample1_16kHz.wav b/lyra/testdata/sample1_16kHz.wav similarity index 100% rename from testdata/sample1_16kHz.wav rename to lyra/testdata/sample1_16kHz.wav diff --git a/testdata/sample1_32kHz.wav b/lyra/testdata/sample1_32kHz.wav similarity index 100% rename from testdata/sample1_32kHz.wav rename to lyra/testdata/sample1_32kHz.wav diff --git a/testdata/sample1_48kHz.wav b/lyra/testdata/sample1_48kHz.wav similarity index 100% rename from testdata/sample1_48kHz.wav rename to lyra/testdata/sample1_48kHz.wav diff --git a/testdata/sample1_8kHz.wav b/lyra/testdata/sample1_8kHz.wav similarity index 100% rename from testdata/sample1_8kHz.wav rename to lyra/testdata/sample1_8kHz.wav diff --git a/testdata/sample2_16kHz.wav b/lyra/testdata/sample2_16kHz.wav similarity index 100% rename from testdata/sample2_16kHz.wav rename to lyra/testdata/sample2_16kHz.wav diff --git a/testdata/sample2_32kHz.wav b/lyra/testdata/sample2_32kHz.wav similarity index 100% rename from testdata/sample2_32kHz.wav rename to lyra/testdata/sample2_32kHz.wav diff --git a/testdata/sample2_48kHz.wav b/lyra/testdata/sample2_48kHz.wav similarity index 100% rename from testdata/sample2_48kHz.wav rename to lyra/testdata/sample2_48kHz.wav diff --git a/testdata/sample2_8kHz.wav b/lyra/testdata/sample2_8kHz.wav similarity index 100% rename from testdata/sample2_8kHz.wav rename to lyra/testdata/sample2_8kHz.wav diff --git a/testdata/two_encoded_packets_16khz.lyra b/lyra/testdata/two_encoded_packets_16khz.lyra similarity index 100% rename from testdata/two_encoded_packets_16khz.lyra rename to lyra/testdata/two_encoded_packets_16khz.lyra diff --git a/testing/BUILD b/lyra/testing/BUILD similarity index 79% rename from testing/BUILD rename to lyra/testing/BUILD index 80f9d95a..f8aabc84 100644 --- a/testing/BUILD +++ b/lyra/testing/BUILD @@ -1,4 +1,4 @@ -package(default_visibility = ["//:__pkg__"]) +package(default_visibility = ["//:__subpackages__"]) licenses(["notice"]) @@ -9,7 +9,7 @@ cc_library( "mock_generative_model.h", ], deps = [ - "//:generative_model_interface", + "//lyra:generative_model_interface", "@com_google_googletest//:gtest", ], ) @@ -21,7 +21,7 @@ cc_library( "mock_feature_extractor.h", ], deps = [ - "//:feature_extractor_interface", + "//lyra:feature_extractor_interface", "@com_google_absl//absl/types:span", "@com_google_googletest//:gtest", ], @@ -34,7 +34,7 @@ cc_library( "mock_vector_quantizer.h", ], deps = [ - "//:vector_quantizer_interface", + "//lyra:vector_quantizer_interface", "@com_google_googletest//:gtest", ], ) @@ -46,7 +46,7 @@ cc_library( "mock_noise_estimator.h", ], deps = [ - "//:noise_estimator_interface", + "//lyra:noise_estimator_interface", "@com_google_absl//absl/types:span", "@com_google_googletest//:gtest", ], @@ -59,7 +59,7 @@ cc_library( "mock_lyra_decoder.h", ], deps = [ - "//:lyra_decoder_interface", + "//lyra:lyra_decoder_interface", "@com_google_absl//absl/types:span", "@com_google_googletest//:gtest", ], @@ -72,7 +72,7 @@ cc_library( "mock_lyra_encoder.h", ], deps = [ - "//:lyra_encoder_interface", + "//lyra:lyra_encoder_interface", "@com_google_absl//absl/types:span", "@com_google_googletest//:gtest", ], @@ -85,8 +85,8 @@ cc_library( "mock_resampler.h", ], deps = [ - "//:resampler", - "//:resampler_interface", + "//lyra:resampler", + "//lyra:resampler_interface", "@com_google_absl//absl/types:span", "@com_google_googletest//:gtest", ], diff --git a/testing/mock_feature_extractor.h b/lyra/testing/mock_feature_extractor.h similarity index 83% rename from testing/mock_feature_extractor.h rename to lyra/testing/mock_feature_extractor.h index 6033467f..677f56a1 100644 --- a/testing/mock_feature_extractor.h +++ b/lyra/testing/mock_feature_extractor.h @@ -14,16 +14,16 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_TESTING_MOCK_FEATURE_EXTRACTOR_H_ -#define LYRA_CODEC_TESTING_MOCK_FEATURE_EXTRACTOR_H_ +#ifndef LYRA_TESTING_MOCK_FEATURE_EXTRACTOR_H_ +#define LYRA_TESTING_MOCK_FEATURE_EXTRACTOR_H_ #include #include #include #include "absl/types/span.h" -#include "feature_extractor_interface.h" #include "gmock/gmock.h" +#include "lyra/feature_extractor_interface.h" namespace chromemedia { namespace codec { @@ -39,4 +39,4 @@ class MockFeatureExtractor : public FeatureExtractorInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_TESTING_MOCK_FEATURE_EXTRACTOR_H_ +#endif // LYRA_TESTING_MOCK_FEATURE_EXTRACTOR_H_ diff --git a/testing/mock_generative_model.h b/lyra/testing/mock_generative_model.h similarity index 93% rename from testing/mock_generative_model.h rename to lyra/testing/mock_generative_model.h index 166c565b..81dd51f5 100644 --- a/testing/mock_generative_model.h +++ b/lyra/testing/mock_generative_model.h @@ -14,15 +14,15 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_TESTING_MOCK_GENERATIVE_MODEL_H_ -#define LYRA_CODEC_TESTING_MOCK_GENERATIVE_MODEL_H_ +#ifndef LYRA_TESTING_MOCK_GENERATIVE_MODEL_H_ +#define LYRA_TESTING_MOCK_GENERATIVE_MODEL_H_ #include #include #include -#include "generative_model_interface.h" #include "gmock/gmock.h" +#include "lyra/generative_model_interface.h" namespace chromemedia { namespace codec { @@ -88,4 +88,4 @@ class MockGenerativeModel : public GenerativeModelInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_TESTING_MOCK_GENERATIVE_MODEL_H_ +#endif // LYRA_TESTING_MOCK_GENERATIVE_MODEL_H_ diff --git a/testing/mock_lyra_decoder.h b/lyra/testing/mock_lyra_decoder.h similarity index 87% rename from testing/mock_lyra_decoder.h rename to lyra/testing/mock_lyra_decoder.h index a133c038..78c31954 100644 --- a/testing/mock_lyra_decoder.h +++ b/lyra/testing/mock_lyra_decoder.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_TESTING_MOCK_LYRA_DECODER_H_ -#define LYRA_CODEC_TESTING_MOCK_LYRA_DECODER_H_ +#ifndef LYRA_TESTING_MOCK_LYRA_DECODER_H_ +#define LYRA_TESTING_MOCK_LYRA_DECODER_H_ #include #include @@ -23,7 +23,7 @@ #include "absl/types/span.h" #include "gmock/gmock.h" -#include "lyra_decoder_interface.h" +#include "lyra/lyra_decoder_interface.h" namespace chromemedia { namespace codec { @@ -49,4 +49,4 @@ class MockLyraDecoder : public LyraDecoderInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_TESTING_MOCK_LYRA_DECODER_H_ +#endif // LYRA_TESTING_MOCK_LYRA_DECODER_H_ diff --git a/testing/mock_lyra_encoder.h b/lyra/testing/mock_lyra_encoder.h similarity index 87% rename from testing/mock_lyra_encoder.h rename to lyra/testing/mock_lyra_encoder.h index b6a0ec75..796f8c7f 100644 --- a/testing/mock_lyra_encoder.h +++ b/lyra/testing/mock_lyra_encoder.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_TESTING_MOCK_LYRA_ENCODER_H_ -#define LYRA_CODEC_TESTING_MOCK_LYRA_ENCODER_H_ +#ifndef LYRA_TESTING_MOCK_LYRA_ENCODER_H_ +#define LYRA_TESTING_MOCK_LYRA_ENCODER_H_ #include #include @@ -23,7 +23,7 @@ #include "absl/types/span.h" #include "gmock/gmock.h" -#include "lyra_encoder_interface.h" +#include "lyra/lyra_encoder_interface.h" namespace chromemedia { namespace codec { @@ -49,4 +49,4 @@ class MockLyraEncoder : public LyraEncoderInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_TESTING_MOCK_LYRA_ENCODER_H_ +#endif // LYRA_TESTING_MOCK_LYRA_ENCODER_H_ diff --git a/testing/mock_noise_estimator.h b/lyra/testing/mock_noise_estimator.h similarity index 85% rename from testing/mock_noise_estimator.h rename to lyra/testing/mock_noise_estimator.h index 03061976..2f8911be 100644 --- a/testing/mock_noise_estimator.h +++ b/lyra/testing/mock_noise_estimator.h @@ -14,14 +14,14 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_TESTING_MOCK_NOISE_ESTIMATOR_H_ -#define LYRA_CODEC_TESTING_MOCK_NOISE_ESTIMATOR_H_ +#ifndef LYRA_TESTING_MOCK_NOISE_ESTIMATOR_H_ +#define LYRA_TESTING_MOCK_NOISE_ESTIMATOR_H_ #include #include "absl/types/span.h" #include "gmock/gmock.h" -#include "noise_estimator_interface.h" +#include "lyra/noise_estimator_interface.h" namespace chromemedia { namespace codec { @@ -41,4 +41,4 @@ class MockNoiseEstimator : public NoiseEstimatorInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_TESTING_MOCK_NOISE_ESTIMATOR_H_ +#endif // LYRA_TESTING_MOCK_NOISE_ESTIMATOR_H_ diff --git a/testing/mock_resampler.h b/lyra/testing/mock_resampler.h similarity index 91% rename from testing/mock_resampler.h rename to lyra/testing/mock_resampler.h index d4616402..038ba5a5 100644 --- a/testing/mock_resampler.h +++ b/lyra/testing/mock_resampler.h @@ -14,16 +14,16 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_TESTING_MOCK_RESAMPLER_H_ -#define LYRA_CODEC_TESTING_MOCK_RESAMPLER_H_ +#ifndef LYRA_TESTING_MOCK_RESAMPLER_H_ +#define LYRA_TESTING_MOCK_RESAMPLER_H_ #include #include #include "absl/types/span.h" #include "gmock/gmock.h" -#include "resampler.h" -#include "resampler_interface.h" +#include "lyra/resampler.h" +#include "lyra/resampler_interface.h" namespace chromemedia { namespace codec { @@ -71,4 +71,4 @@ class MockResampler : public ResamplerInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_TESTING_MOCK_RESAMPLER_H_ +#endif // LYRA_TESTING_MOCK_RESAMPLER_H_ diff --git a/testing/mock_vector_quantizer.h b/lyra/testing/mock_vector_quantizer.h similarity index 85% rename from testing/mock_vector_quantizer.h rename to lyra/testing/mock_vector_quantizer.h index 385d7df0..202c7479 100644 --- a/testing/mock_vector_quantizer.h +++ b/lyra/testing/mock_vector_quantizer.h @@ -14,15 +14,15 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_TESTING_MOCK_VECTOR_QUANTIZER_H_ -#define LYRA_CODEC_TESTING_MOCK_VECTOR_QUANTIZER_H_ +#ifndef LYRA_TESTING_MOCK_VECTOR_QUANTIZER_H_ +#define LYRA_TESTING_MOCK_VECTOR_QUANTIZER_H_ #include #include #include #include "gmock/gmock.h" -#include "vector_quantizer_interface.h" +#include "lyra/vector_quantizer_interface.h" namespace chromemedia { namespace codec { @@ -42,4 +42,4 @@ class MockVectorQuantizer : public VectorQuantizerInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_TESTING_MOCK_VECTOR_QUANTIZER_H_ +#endif // LYRA_TESTING_MOCK_VECTOR_QUANTIZER_H_ diff --git a/tflite_model_wrapper.cc b/lyra/tflite_model_wrapper.cc similarity index 99% rename from tflite_model_wrapper.cc rename to lyra/tflite_model_wrapper.cc index 0f884294..e3229405 100644 --- a/tflite_model_wrapper.cc +++ b/lyra/tflite_model_wrapper.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "tflite_model_wrapper.h" +#include "lyra/tflite_model_wrapper.h" #include #include diff --git a/tflite_model_wrapper.h b/lyra/tflite_model_wrapper.h similarity index 92% rename from tflite_model_wrapper.h rename to lyra/tflite_model_wrapper.h index b9647f3a..87aba3b6 100644 --- a/tflite_model_wrapper.h +++ b/lyra/tflite_model_wrapper.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef THIRD_PARTY_LYRA_CODEC_TFLITE_MODEL_WRAPPER_H_ -#define THIRD_PARTY_LYRA_CODEC_TFLITE_MODEL_WRAPPER_H_ +#ifndef LYRA_TFLITE_MODEL_WRAPPER_H_ +#define LYRA_TFLITE_MODEL_WRAPPER_H_ #include #include @@ -69,4 +69,4 @@ class TfLiteModelWrapper { } // namespace codec } // namespace chromemedia -#endif // THIRD_PARTY_LYRA_CODEC_TFLITE_MODEL_WRAPPER_H_ +#endif // LYRA_TFLITE_MODEL_WRAPPER_H_ diff --git a/tflite_model_wrapper_test.cc b/lyra/tflite_model_wrapper_test.cc similarity index 92% rename from tflite_model_wrapper_test.cc rename to lyra/tflite_model_wrapper_test.cc index 3f6822b2..dd4219bd 100644 --- a/tflite_model_wrapper_test.cc +++ b/lyra/tflite_model_wrapper_test.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "tflite_model_wrapper.h" +#include "lyra/tflite_model_wrapper.h" #include #include @@ -39,8 +39,8 @@ class TfLiteModelWrapperTest : public testing::TestWithParam {}; TEST_P(TfLiteModelWrapperTest, CreateSucceedsAndMethodsRun) { const bool int8_quantized = GetParam(); auto model_wrapper = TfLiteModelWrapper::Create( - ghc::filesystem::current_path() / "model_coeffs/lyragan.tflite", true, - int8_quantized); + ghc::filesystem::current_path() / "lyra/model_coeffs/lyragan.tflite", + true, int8_quantized); ASSERT_NE(model_wrapper, nullptr); absl::Span input = model_wrapper->get_input_tensor(0); std::fill(input.begin(), input.end(), 0); diff --git a/vector_quantizer_interface.h b/lyra/vector_quantizer_interface.h similarity index 90% rename from vector_quantizer_interface.h rename to lyra/vector_quantizer_interface.h index 1508e09d..f949cd4d 100644 --- a/vector_quantizer_interface.h +++ b/lyra/vector_quantizer_interface.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_VECTOR_QUANTIZER_INTERFACE_H_ -#define LYRA_CODEC_VECTOR_QUANTIZER_INTERFACE_H_ +#ifndef LYRA_VECTOR_QUANTIZER_INTERFACE_H_ +#define LYRA_VECTOR_QUANTIZER_INTERFACE_H_ #include #include @@ -43,4 +43,4 @@ class VectorQuantizerInterface { } // namespace codec } // namespace chromemedia -#endif // LYRA_CODEC_VECTOR_QUANTIZER_INTERFACE_H_ +#endif // LYRA_VECTOR_QUANTIZER_INTERFACE_H_ diff --git a/wav_utils.cc b/lyra/wav_utils.cc similarity index 98% rename from wav_utils.cc rename to lyra/wav_utils.cc index f327a2cd..9c06059c 100644 --- a/wav_utils.cc +++ b/lyra/wav_utils.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "wav_utils.h" +#include "lyra/wav_utils.h" #include #include diff --git a/wav_utils.h b/lyra/wav_utils.h similarity index 94% rename from wav_utils.h rename to lyra/wav_utils.h index 0298b7c6..3167bcfc 100644 --- a/wav_utils.h +++ b/lyra/wav_utils.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef LYRA_CODEC_WAV_UTILS_H_ -#define LYRA_CODEC_WAV_UTILS_H_ +#ifndef LYRA_WAV_UTILS_H_ +#define LYRA_WAV_UTILS_H_ #include #include @@ -48,4 +48,4 @@ absl::Status Write16BitWavFileFromVector(const std::string& file_name, } // namespace chromemedia::codec -#endif // LYRA_CODEC_WAV_UTILS_H_ +#endif // LYRA_WAV_UTILS_H_ diff --git a/wav_utils_test.cc b/lyra/wav_utils_test.cc similarity index 96% rename from wav_utils_test.cc rename to lyra/wav_utils_test.cc index 35318202..c6f7f190 100644 --- a/wav_utils_test.cc +++ b/lyra/wav_utils_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "wav_utils.h" +#include "lyra/wav_utils.h" #include #include @@ -36,7 +36,7 @@ class WavUtilTest : public testing::Test { // std::string_view. absl::StatusOr ReadWav(const std::string& file_name) { const ghc::filesystem::path wav_path = - ghc::filesystem::current_path() / "testdata" / file_name; + ghc::filesystem::current_path() / "lyra/testdata" / file_name; return Read16BitWavFileToVector(wav_path.string()); } }; diff --git a/zero_feature_estimator.h b/lyra/zero_feature_estimator.h similarity index 84% rename from zero_feature_estimator.h rename to lyra/zero_feature_estimator.h index b493c36b..434b6e53 100644 --- a/zero_feature_estimator.h +++ b/lyra/zero_feature_estimator.h @@ -14,13 +14,13 @@ * limitations under the License. */ -#ifndef THIRD_PARTY_LYRA_CODEC_ZERO_FEATURE_ESTIMATOR_H_ -#define THIRD_PARTY_LYRA_CODEC_ZERO_FEATURE_ESTIMATOR_H_ +#ifndef LYRA_ZERO_FEATURE_ESTIMATOR_H_ +#define LYRA_ZERO_FEATURE_ESTIMATOR_H_ #include #include "absl/types/span.h" -#include "feature_estimator_interface.h" +#include "lyra/feature_estimator_interface.h" namespace chromemedia { namespace codec { @@ -44,4 +44,4 @@ class ZeroFeatureEstimator : public FeatureEstimatorInterface { } // namespace codec } // namespace chromemedia -#endif // THIRD_PARTY_LYRA_CODEC_ZERO_FEATURE_ESTIMATOR_H_ +#endif // LYRA_ZERO_FEATURE_ESTIMATOR_H_ diff --git a/third_party/BUILD b/third_party/BUILD deleted file mode 100644 index 8125e341..00000000 --- a/third_party/BUILD +++ /dev/null @@ -1,5 +0,0 @@ -licenses(["notice"]) # Apache License 2.0 - -exports_files(["LICENSE"]) - -package(default_visibility = ["//visibility:public"]) diff --git a/third_party/com_google_absl_f863b622fe13612433fdf43f76547d5edda0c93001.diff b/third_party/com_google_absl_f863b622fe13612433fdf43f76547d5edda0c93001.diff deleted file mode 100644 index 46a28270..00000000 --- a/third_party/com_google_absl_f863b622fe13612433fdf43f76547d5edda0c93001.diff +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/absl/time/internal/cctz/BUILD.bazel b/absl/time/internal/cctz/BUILD.bazel -index 9fceffe..e7f9d01 100644 ---- a/absl/time/internal/cctz/BUILD.bazel -+++ b/absl/time/internal/cctz/BUILD.bazel -@@ -69,8 +69,5 @@ cc_library( - "include/cctz/zone_info_source.h", - ], - linkopts = select({ -- ":osx": [ -- "-framework Foundation", -- ], - ":ios": [ - "-framework Foundation", - ],