1212logging .basicConfig (level = logging .INFO )
1313logger = logging .getLogger (__name__ )
1414
15- jigsaw = jigsawstack .JigsawStack (api_key = os .getenv ("JIGSAWSTACK_API_KEY" ))
16- async_jigsaw = jigsawstack .AsyncJigsawStack (api_key = os .getenv ("JIGSAWSTACK_API_KEY" ))
15+ jigsaw = jigsawstack .JigsawStack (
16+ api_key = os .getenv ("JIGSAWSTACK_API_KEY" ),
17+ base_url = os .getenv ("JIGSAWSTACK_BASE_URL" ) + "/api"
18+ if os .getenv ("JIGSAWSTACK_BASE_URL" )
19+ else "https://api.jigsawstack.com" ,
20+ headers = {"x-jigsaw-skip-cache" : "true" },
21+ )
22+ async_jigsaw = jigsawstack .AsyncJigsawStack (
23+ api_key = os .getenv ("JIGSAWSTACK_API_KEY" ),
24+ base_url = os .getenv ("JIGSAWSTACK_BASE_URL" ) + "/api"
25+ if os .getenv ("JIGSAWSTACK_BASE_URL" )
26+ else "https://api.jigsawstack.com" ,
27+ headers = {"x-jigsaw-skip-cache" : "true" },
28+ )
1729
1830AUDIO_URL = AUDIO_URL_LONG = "https://jigsawstack.com/preview/stt-example.wav"
1931
119131class TestAudioSync :
120132 """Test synchronous audio speech-to-text methods"""
121133
122- @pytest .mark .parametrize ("test_case" , TEST_CASES , ids = [tc ["name" ] for tc in TEST_CASES ])
134+ @pytest .mark .parametrize (
135+ "test_case" , TEST_CASES , ids = [tc ["name" ] for tc in TEST_CASES ]
136+ )
123137 def test_speech_to_text (self , test_case ):
124138 """Test synchronous speech-to-text with various inputs"""
125139 try :
126140 if test_case .get ("blob" ):
127141 # Download audio content
128142 blob_content = requests .get (test_case ["blob" ]).content
129- result = jigsaw .audio .speech_to_text (blob_content , test_case .get ("options" , {}))
143+ result = jigsaw .audio .speech_to_text (
144+ blob_content , test_case .get ("options" , {})
145+ )
130146 else :
131147 # Use params directly
132148 result = jigsaw .audio .speech_to_text (test_case ["params" ])
133149 # Verify response structure
134150 assert result ["success" ]
135- assert result .get ("text" , None ) is not None and isinstance (result ["text" ], str )
151+ assert result .get ("text" , None ) is not None and isinstance (
152+ result ["text" ], str
153+ )
136154
137155 # Check for chunks
138156 if result .get ("chunks" , None ):
@@ -154,7 +172,9 @@ def test_speech_to_text_webhook(self, test_case):
154172 if test_case .get ("blob" ):
155173 # Download audio content
156174 blob_content = requests .get (test_case ["blob" ]).content
157- result = jigsaw .audio .speech_to_text (blob_content , test_case .get ("options" , {}))
175+ result = jigsaw .audio .speech_to_text (
176+ blob_content , test_case .get ("options" , {})
177+ )
158178 else :
159179 # Use params directly
160180 result = jigsaw .audio .speech_to_text (test_case ["params" ])
@@ -169,7 +189,9 @@ def test_speech_to_text_webhook(self, test_case):
169189class TestAudioAsync :
170190 """Test asynchronous audio speech-to-text methods"""
171191
172- @pytest .mark .parametrize ("test_case" , TEST_CASES , ids = [tc ["name" ] for tc in TEST_CASES ])
192+ @pytest .mark .parametrize (
193+ "test_case" , TEST_CASES , ids = [tc ["name" ] for tc in TEST_CASES ]
194+ )
173195 @pytest .mark .asyncio
174196 async def test_speech_to_text_async (self , test_case ):
175197 """Test asynchronous speech-to-text with various inputs"""
@@ -186,7 +208,9 @@ async def test_speech_to_text_async(self, test_case):
186208
187209 # Verify response structure
188210 assert result ["success" ]
189- assert result .get ("text" , None ) is not None and isinstance (result ["text" ], str )
211+ assert result .get ("text" , None ) is not None and isinstance (
212+ result ["text" ], str
213+ )
190214
191215 # Check for chunks
192216 if result .get ("chunks" , None ):
@@ -196,7 +220,9 @@ async def test_speech_to_text_async(self, test_case):
196220 if result .get ("speakers" , None ):
197221 assert isinstance (result ["speakers" ], list )
198222 except JigsawStackError as e :
199- pytest .fail (f"Unexpected JigsawStackError in async { test_case ['name' ]} : { e } " )
223+ pytest .fail (
224+ f"Unexpected JigsawStackError in async { test_case ['name' ]} : { e } "
225+ )
200226
201227 @pytest .mark .parametrize (
202228 "test_case" , WEBHOOK_TEST_CASES , ids = [tc ["name" ] for tc in WEBHOOK_TEST_CASES ]
@@ -222,4 +248,6 @@ async def test_speech_to_text_webhook_async(self, test_case):
222248
223249 except JigsawStackError as e :
224250 # Webhook URLs might fail if invalid
225- print (f"Expected possible error for async webhook test { test_case ['name' ]} : { e } " )
251+ print (
252+ f"Expected possible error for async webhook test { test_case ['name' ]} : { e } "
253+ )
0 commit comments