12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
- import mlrun
15
+ import os
16
16
import tempfile
17
+
18
+ import mlrun
17
19
import pytest
18
20
19
21
@@ -31,6 +33,7 @@ def test_generate_multi_speakers_audio(file_format, bits_per_sample):
31
33
"v2/en_speaker_0" ,
32
34
"v2/en_speaker_1" ,
33
35
],
36
+ "engine" : "bark" ,
34
37
"use_small_models" : True ,
35
38
"use_gpu" : False ,
36
39
"offload_cpu" : True ,
@@ -45,6 +48,42 @@ def test_generate_multi_speakers_audio(file_format, bits_per_sample):
45
48
],
46
49
artifact_path = test_directory ,
47
50
)
48
- assert function_run .error == "Run state (completed) is not in error state "
51
+ assert function_run .error == ""
49
52
for key in ["audio_files" , "audio_files_dataframe" , "text_to_speech_errors" ]:
50
53
assert key in function_run .outputs and function_run .outputs [key ] is not None
54
+
55
+
56
+ @pytest .mark .skipif (
57
+ condition = os .getenv ("OPENAI_API_BASE" ) is None
58
+ and os .getenv ("OPENAI_API_KEY" ) is None ,
59
+ reason = "OpenAI API key and base URL are required to run this test" ,
60
+ )
61
+ @pytest .mark .parametrize ("file_format,bits_per_sample" , [("wav" , 8 ), ("mp3" , None )])
62
+ def test_generate_multi_speakers_audio_openai (file_format , bits_per_sample ):
63
+ text_to_audio_generator_function = mlrun .import_function ("function.yaml" )
64
+ with tempfile .TemporaryDirectory () as test_directory :
65
+ function_run = text_to_audio_generator_function .run (
66
+ handler = "generate_multi_speakers_audio" ,
67
+ inputs = {"data_path" : "data/test_data.txt" },
68
+ params = {
69
+ "output_directory" : test_directory ,
70
+ "speakers" : {"Agent" : 0 , "Client" : 1 },
71
+ "available_voices" : [
72
+ "alloy" ,
73
+ "echo" ,
74
+ ],
75
+ "engine" : "openai" ,
76
+ "file_format" : file_format ,
77
+ "bits_per_sample" : bits_per_sample ,
78
+ },
79
+ local = True ,
80
+ returns = [
81
+ "audio_files: path" ,
82
+ "audio_files_dataframe: dataset" ,
83
+ "text_to_speech_errors: file" ,
84
+ ],
85
+ artifact_path = test_directory ,
86
+ )
87
+ assert function_run .error == ""
88
+ for key in ["audio_files" , "audio_files_dataframe" , "text_to_speech_errors" ]:
89
+ assert key in function_run .outputs and function_run .outputs [key ] is not None
0 commit comments