aallam / openai-kotlin

OpenAI API client for Kotlin with multiplatform and coroutines capabilities.
MIT License
1.49k stars 179 forks source link

FileSystem.RESOURCES unresolved #351

Open NovemberJay opened 5 months ago

NovemberJay commented 5 months ago

Hi, I am trying to read an audio from src/androidMain/res then make transcription. Here is my code:

suspend fun func() {
    val myAudioPath = "test_audio.mp3".toPath()
    val audioSource = FileSource(path = myAudioPath, fileSystem = FileSystem.RESOURCES)
    val request = TranscriptionRequest(
        audio = audioSource,
        model = ModelId("whisper-1"),
    )
    val transcription = openAI.transcription(request)
    println(transcription.text)
}

However, I was warned "Unresolved reference: RESOURCES" while I could build the program normally. When I began running the program, I received an error: "file not found: test_audio.mp3". Is there any wrong with my code ? How can I fix it?

Furthermore, when I call FileSource(name, source), I found out that ByteArray do not have a member function named asSource(), however, such function appeared here. Could you please tell me how can I use it?