looking to use kotlin multiplatfrom with python an...
# multiplatform
y
looking to use kotlin multiplatfrom with python anyone got some sort of a starter or an idea on how to do that i have tried making a python module inside my composeApp like so then i added a python file there. and using expect and actuall i added this TranscribeVideo in JVM but i dont think it seem to run correct it always prints out an empty string
Copy code
actual fun TranscribeVideo(filepath: String): String {
    var transcript = "nothing"
    try {
        // Build the command to run the Python script
        val command = listOf(
            "python",
            "absolute path to the Python script",
            filepath
        )

        // Execute the Python script
        val process = Runtime.getRuntime().exec(command.toTypedArray())


        // Read both the standard output and error streams
        val reader = BufferedReader(InputStreamReader(process.inputStream))
        val errorReader = BufferedReader(InputStreamReader(process.errorStream))

        val output = StringBuilder()

        // Read the standard output
        var line: String? = null
        while (reader.readLine().also { line = it } != null) {
            output.append(line).append('\n')
        }

        // Read the error output (if any)
        var errorLine: String? = null
        while (errorReader.readLine().also { errorLine = it } != null) {
            output.append(errorLine).append('\n')
        }

        // Now 'output' contains the combined output from the Python script
        transcript = output.toString().trim()

        println("Transcript: $transcript")
    } catch (e: Exception) {
        throw e
    }
    return transcript
}
any idea on how to run it ?? even logging of the python script would help.
l
There is no multiplatform API to run platform executables. You have to do it in the platform-specific part. So if you want to use
Runtime.exec
you have to do it from the JVM target code.
y
its happening tho in JVM the actual fun proves that