• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
2# SPDX-License-Identifier: MIT
3
4import os
5
6import numpy as np
7
8from context import audio_utils
9
10labels = {0: 'a', 1: 'b', 2: 'c', 3: 'd', 4: 'e', 5: 'f', 6: 'g', 7: 'h', 8: 'i', 9: 'j', 10: 'k', 11: 'l', 12: 'm',
11          13: 'n',
12          14: 'o', 15: 'p', 16: 'q', 17: 'r', 18: 's', 19: 't', 20: 'u', 21: 'v', 22: 'w', 23: 'x', 24: 'y',
13          25: 'z',
14          26: "'", 27: ' ', 28: '$'}
15
16
17def test_labels(test_data_folder):
18    assert len(labels) == 29
19    assert labels[26] == "\'"
20    assert labels[27] == r" "
21    assert labels[28] == "$"
22
23
24def test_decoder(test_data_folder):
25
26    output_tensor = os.path.join(test_data_folder, "inference_output.npy")
27    encoded = np.load(output_tensor)
28    decoded_text = audio_utils.decode(encoded, labels)
29    assert decoded_text == "my voice is my pass"
30