You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Caused by io.ktor.client.plugins.ClientRequestException: Client request(POST https://api.openai.com/v1/audio/transcriptions) invalid: 400 . Text: "{
"error": {
"message": "Could not parse multipart form",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
"
at io.ktor.client.plugins.DefaultResponseValidationKt$addDefaultResponseValidation$1$1.invokeSuspend(DefaultResponseValidation.kt:54)
at io.ktor.client.plugins.DefaultResponseValidationKt$addDefaultResponseValidation$1$1.invoke(:8)
at io.ktor.client.plugins.DefaultResponseValidationKt$addDefaultResponseValidation$1$1.invoke(:4)
at io.ktor.client.plugins.HttpCallValidator.validateResponse(HttpCallValidator.kt:51)
at io.ktor.client.plugins.HttpCallValidator.access$validateResponse(HttpCallValidator.kt:43)
at io.ktor.client.plugins.HttpCallValidator$Companion$install$3.invokeSuspend(HttpCallValidator.kt:152)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7872)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
`
public suspend fun transcribeText(mp3Path: String): String {
val path = mp3Path.toPath()
val audioSource = FileSource(path = path, fileSystem = FileSystem.SYSTEM)
val request = TranscriptionRequest(
audio = audioSource,
model = ModelId("whisper-1"),
)
var result = openAI.transcription(request)
return result.text
}
`
The text was updated successfully, but these errors were encountered:
I have come across this issue before, where the problem lies in the unsupported form boundary string for the Content-Type header (e.g., okhttp's default boundary string is not supported). To resolve this, you need to change the boundary string to a different value. I haven't extensively studied how to change this value specifically in ktor, but that should be the general solution.
Here's an example of the Content-Type header with a form boundary string:
// WebAppBoundar is the form boundary string
Content-Type: multipart/form-data; boundary=WebAppBoundar
Description
I get this exception from time to time when calling the transcription API. It happens on my real device and on virtual devices.
I found some additional information about it here: https://community.openai.com/t/calling-whisper-api-using-curl-request-keeps-giving-error/81510
Caused by io.ktor.client.plugins.ClientRequestException: Client request(POST https://api.openai.com/v1/audio/transcriptions) invalid: 400 . Text: "{
"error": {
"message": "Could not parse multipart form",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
"
at io.ktor.client.plugins.DefaultResponseValidationKt$addDefaultResponseValidation$1$1.invokeSuspend(DefaultResponseValidation.kt:54)
at io.ktor.client.plugins.DefaultResponseValidationKt$addDefaultResponseValidation$1$1.invoke(:8)
at io.ktor.client.plugins.DefaultResponseValidationKt$addDefaultResponseValidation$1$1.invoke(:4)
at io.ktor.client.plugins.HttpCallValidator.validateResponse(HttpCallValidator.kt:51)
at io.ktor.client.plugins.HttpCallValidator.access$validateResponse(HttpCallValidator.kt:43)
at io.ktor.client.plugins.HttpCallValidator$Companion$install$3.invokeSuspend(HttpCallValidator.kt:152)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7872)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Steps to Reproduce
Environment
Additional Info
My code to transcribe in kotlin:
`
public suspend fun transcribeText(mp3Path: String): String {
val path = mp3Path.toPath()
val audioSource = FileSource(path = path, fileSystem = FileSystem.SYSTEM)
`
The text was updated successfully, but these errors were encountered: