"tests/models/electra/test_modeling_electra.py" did not exist on "5deed37f9f1a0f5794a2a7cd02164ff265c59524"
test_speech_to_text.py 1.11 KB
Newer Older
Sylvain Gugger's avatar
Sylvain Gugger committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# coding=utf-8
# Copyright 2023 HuggingFace Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import unittest

Aymeric Roucher's avatar
Aymeric Roucher committed
18
import numpy as np
Sylvain Gugger's avatar
Sylvain Gugger committed
19

Aymeric Roucher's avatar
Aymeric Roucher committed
20
from transformers import load_tool
Sylvain Gugger's avatar
Sylvain Gugger committed
21

Aymeric Roucher's avatar
Aymeric Roucher committed
22
from .test_tools_common import ToolTesterMixin
Sylvain Gugger's avatar
Sylvain Gugger committed
23
24
25
26
27
28
29
30


class SpeechToTextToolTester(unittest.TestCase, ToolTesterMixin):
    def setUp(self):
        self.tool = load_tool("speech-to-text")
        self.tool.setup()

    def test_exact_match_arg(self):
Aymeric Roucher's avatar
Aymeric Roucher committed
31
32
        result = self.tool(np.ones(3000))
        self.assertEqual(result, " Thank you.")
Sylvain Gugger's avatar
Sylvain Gugger committed
33
34

    def test_exact_match_kwarg(self):
Aymeric Roucher's avatar
Aymeric Roucher committed
35
36
        result = self.tool(audio=np.ones(3000))
        self.assertEqual(result, " Thank you.")