youssef
12/31/2023, 9:25 AMactual 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.loke
12/31/2023, 11:15 AMRuntime.exec
you have to do it from the JVM target code.youssef
12/31/2023, 12:11 PM