File tree Expand file tree Collapse file tree 1 file changed +11
-14
lines changed
Expand file tree Collapse file tree 1 file changed +11
-14
lines changed Original file line number Diff line number Diff line change @@ -80,11 +80,9 @@ def speech_to_text(
8080 ) -> Union [SpeechToTextResponse , SpeechToTextWebhookResponse ]:
8181 options = options or {}
8282 path = "/ai/transcribe"
83- content_type = options .get ("content_type" , "application/octet-stream" )
84- headers = {"Content-Type" : content_type }
85- if isinstance (
86- blob , dict
87- ): # If params is provided as a dict, we assume it's the first argument
83+ params = options or {}
84+ if isinstance (blob , dict ):
85+ # URL or file_store_key based request
8886 resp = Request (
8987 config = self .config ,
9088 path = path ,
@@ -93,13 +91,13 @@ def speech_to_text(
9391 ).perform_with_content ()
9492 return resp
9593
94+ files = {"file" : blob }
9695 resp = Request (
9796 config = self .config ,
9897 path = path ,
99- params = options ,
100- data = blob ,
101- headers = headers ,
98+ params = params ,
10299 verb = "post" ,
100+ files = files ,
103101 ).perform_with_content ()
104102 return resp
105103
@@ -136,8 +134,7 @@ async def speech_to_text(
136134 ) -> Union [SpeechToTextResponse , SpeechToTextWebhookResponse ]:
137135 options = options or {}
138136 path = "/ai/transcribe"
139- content_type = options .get ("content_type" , "application/octet-stream" )
140- headers = {"Content-Type" : content_type }
137+ params = options or {}
141138 if isinstance (blob , dict ):
142139 resp = await AsyncRequest (
143140 config = self .config ,
@@ -146,13 +143,13 @@ async def speech_to_text(
146143 verb = "post" ,
147144 ).perform_with_content ()
148145 return resp
149-
146+
147+ files = {"file" : blob }
150148 resp = await AsyncRequest (
151149 config = self .config ,
152150 path = path ,
153- params = options ,
154- data = blob ,
155- headers = headers ,
151+ params = params ,
156152 verb = "post" ,
153+ files = files ,
157154 ).perform_with_content ()
158155 return resp
You can’t perform that action at this time.
0 commit comments