File size: 611 Bytes
313814b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import enum

from pydantic import BaseModel

from speaches.core import Word


class ResponseFormat(enum.StrEnum):
    JSON = "json"
    TEXT = "text"
    VERBOSE_JSON = "verbose_json"


# https://platform.openai.com/docs/api-reference/audio/json-object
class TranscriptionResponse(BaseModel):
    text: str


# Subset of https://platform.openai.com/docs/api-reference/audio/verbose-json-object
class TranscriptionVerboseResponse(BaseModel):
    task: str = "transcribe"
    duration: float
    text: str
    words: list[
        Word
    ]  # Different from OpenAI's `words`. `Word.text` instead of `Word.word`