Skip to content

Commit 364f3f2

Browse files
committed
doc: update readme
1 parent 5a70cb5 commit 364f3f2

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ try {
9292
- [ImageGenerations](guides/Features.md#imagegenerations)
9393
- [Edits](guides/Features.md#edits)
9494
- [AudioTranscriptions](guides/Features.md#audioTranscriptions)
95+
- [AudioTranslations](guides/Features.md#audioTranslations)
9596

9697
## ℹ️ Sample apps
9798

guides/Features.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- [ImageGenerations](#imagegenerations)
88
- [Edits](#edits)
99
- [AudioTranscriptions](#audioTranscriptions)
10+
- [AudioTranslations](#audioTranslations)
1011

1112
## ListModels
1213

@@ -308,4 +309,56 @@ try {
308309
} catch (e: exception) {
309310
// catch any error that may occurs on api call.
310311
}
312+
```
313+
314+
## AudioTranslations
315+
316+
The audioTranscriptions api is used to translates audio into English.
317+
318+
### Swift
319+
320+
```swift
321+
var yChat: YChat {
322+
YChatCompanion.shared.create(apiKey: "your-api-key")
323+
}
324+
325+
guard let audioFileUrl = Bundle.main.url(forResource: "audio", withExtension: "m4a") else {
326+
print("Unable to find the audio file.")
327+
return
328+
}
329+
330+
let audioData = try! Data(contentsOf: audioFileUrl)
331+
332+
do {
333+
let result = try await yChat.audioTranslations()
334+
.setModel(model: "whisper-1")
335+
.setPrompt(prompt: "")
336+
.setResponseFormat(format: "json")
337+
.setTemperature(temperature: 0.4)
338+
.execute(filename: "audio.m4a", audioFile: audioData)
339+
} catch {
340+
// catch any error that may occurs on api call.
341+
}
342+
```
343+
344+
### Kotlin
345+
346+
```kotlin
347+
val yChat by lazy {
348+
YChat.create("your-api-key")
349+
}
350+
351+
val inputStream = application.resources.openRawResource(R.raw.audio)
352+
val byteArray = inputStream.readBytes()
353+
354+
try {
355+
val result = yChat.audioTranslations()
356+
.setModel("whisper-1")
357+
.setPrompt("")
358+
.setResponseFormat("json")
359+
.setTemperature(0.4)
360+
.execute("audio.m4a", byteArray)
361+
} catch (e: exception) {
362+
// catch any error that may occurs on api call.
363+
}
311364
```

0 commit comments

Comments
 (0)