translations.d.ts 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import { APIResource } from "../../resource.js";
  2. import * as Core from "../../core.js";
  3. import * as AudioAPI from "./audio.js";
  4. import * as TranscriptionsAPI from "./transcriptions.js";
  5. export declare class Translations extends APIResource {
  6. /**
  7. * Translates audio into English.
  8. *
  9. * @example
  10. * ```ts
  11. * const translation = await client.audio.translations.create({
  12. * file: fs.createReadStream('speech.mp3'),
  13. * model: 'whisper-1',
  14. * });
  15. * ```
  16. */
  17. create(body: TranslationCreateParams<'json' | undefined>, options?: Core.RequestOptions): Core.APIPromise<Translation>;
  18. create(body: TranslationCreateParams<'verbose_json'>, options?: Core.RequestOptions): Core.APIPromise<TranslationVerbose>;
  19. create(body: TranslationCreateParams<'text' | 'srt' | 'vtt'>, options?: Core.RequestOptions): Core.APIPromise<string>;
  20. create(body: TranslationCreateParams, options?: Core.RequestOptions): Core.APIPromise<Translation>;
  21. }
  22. export interface Translation {
  23. text: string;
  24. }
  25. export interface TranslationVerbose {
  26. /**
  27. * The duration of the input audio.
  28. */
  29. duration: number;
  30. /**
  31. * The language of the output translation (always `english`).
  32. */
  33. language: string;
  34. /**
  35. * The translated text.
  36. */
  37. text: string;
  38. /**
  39. * Segments of the translated text and their corresponding details.
  40. */
  41. segments?: Array<TranscriptionsAPI.TranscriptionSegment>;
  42. }
  43. export type TranslationCreateResponse = Translation | TranslationVerbose;
  44. export interface TranslationCreateParams<ResponseFormat extends AudioAPI.AudioResponseFormat | undefined = AudioAPI.AudioResponseFormat | undefined> {
  45. /**
  46. * The audio file object (not file name) translate, in one of these formats: flac,
  47. * mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
  48. */
  49. file: Core.Uploadable;
  50. /**
  51. * ID of the model to use. Only `whisper-1` (which is powered by our open source
  52. * Whisper V2 model) is currently available.
  53. */
  54. model: (string & {}) | AudioAPI.AudioModel;
  55. /**
  56. * An optional text to guide the model's style or continue a previous audio
  57. * segment. The
  58. * [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting)
  59. * should be in English.
  60. */
  61. prompt?: string;
  62. /**
  63. * The format of the output, in one of these options: `json`, `text`, `srt`,
  64. * `verbose_json`, or `vtt`.
  65. */
  66. response_format?: 'json' | 'text' | 'srt' | 'verbose_json' | 'vtt';
  67. /**
  68. * The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
  69. * output more random, while lower values like 0.2 will make it more focused and
  70. * deterministic. If set to 0, the model will use
  71. * [log probability](https://en.wikipedia.org/wiki/Log_probability) to
  72. * automatically increase the temperature until certain thresholds are hit.
  73. */
  74. temperature?: number;
  75. }
  76. export declare namespace Translations {
  77. export { type Translation as Translation, type TranslationVerbose as TranslationVerbose, type TranslationCreateResponse as TranslationCreateResponse, type TranslationCreateParams as TranslationCreateParams, };
  78. }
  79. //# sourceMappingURL=translations.d.ts.map