-
Notifications
You must be signed in to change notification settings - Fork 6.5k
/
Copy pathbeta_snippets_test.py
108 lines (79 loc) · 3.14 KB
/
beta_snippets_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Copyright 2018 Google LLC
#
# 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
#
# https://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 os
from google.api_core.retry import Retry
import pytest
from beta_snippets import (
transcribe_file_with_auto_punctuation,
transcribe_file_with_diarization,
transcribe_file_with_enhanced_model,
transcribe_file_with_metadata,
transcribe_file_with_multichannel,
transcribe_file_with_multilanguage,
transcribe_file_with_spoken_punctuation_end_emojis,
transcribe_file_with_word_level_confidence,
)
RESOURCES = os.path.join(os.path.dirname(__file__), "resources")
@Retry()
def test_transcribe_file_with_enhanced_model(capsys: pytest.CaptureFixture) -> None:
result = transcribe_file_with_enhanced_model()
out, _ = capsys.readouterr()
assert "Chrome" in out
assert result is not None
@Retry()
def test_transcribe_file_with_metadata(capsys: pytest.CaptureFixture) -> None:
result = transcribe_file_with_metadata()
out, _ = capsys.readouterr()
assert "Chrome" in out
assert result is not None
@Retry()
def test_transcribe_file_with_auto_punctuation(capsys: pytest.CaptureFixture) -> None:
result = transcribe_file_with_auto_punctuation()
out, _ = capsys.readouterr()
assert "First alternative of result " in out
assert result is not None
@Retry()
def test_transcribe_diarization(capsys: pytest.CaptureFixture) -> None:
result = transcribe_file_with_diarization()
out, err = capsys.readouterr()
assert "word:" in out
assert "speaker_tag:" in out
assert result is not None
@Retry()
def test_transcribe_multichannel_file(capsys: pytest.CaptureFixture) -> None:
result = transcribe_file_with_multichannel()
out, err = capsys.readouterr()
assert "OK Google stream stranger things from Netflix to my TV" in out
assert result is not None
@Retry()
def test_transcribe_multilanguage_file(capsys: pytest.CaptureFixture) -> None:
result = transcribe_file_with_multilanguage()
out, err = capsys.readouterr()
assert "First alternative of result" in out
assert "Transcript" in out
assert result is not None
@Retry()
def test_transcribe_word_level_confidence(capsys: pytest.CaptureFixture) -> None:
result = transcribe_file_with_word_level_confidence()
out, err = capsys.readouterr()
assert "OK Google stream stranger things from Netflix to my TV" in out
assert result is not None
@Retry()
def test_transcribe_file_with_spoken_punctuation_end_emojis(
capsys: pytest.CaptureFixture,
) -> None:
result = transcribe_file_with_spoken_punctuation_end_emojis()
out, err = capsys.readouterr()
assert "First alternative of result " in out
assert result is not None