Test

<back to all web services

SpeechToText

AI

Convert speech to text

import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class TextOutput:
    """
    Output object for generated text
    """

    # @ApiMember(Description="The generated text")
    text: Optional[str] = None
    """
    The generated text
    """


# @Api(Description="Response object for text generation requests")
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class TextGenerationResponse:
    """
    Response object for text generation requests
    """

    # @ApiMember(Description="List of generated text outputs")
    results: Optional[List[TextOutput]] = None
    """
    List of generated text outputs
    """


    # @ApiMember(Description="Detailed response status information")
    response_status: Optional[ResponseStatus] = None
    """
    Detailed response status information
    """


# @Api(Description="Convert speech to text")
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class SpeechToText(IGeneration):
    """
    Convert speech to text
    """

    # @ApiMember(Description="The audio stream containing the speech to be transcribed")
    # @Required()
    audio: Optional[str] = None
    """
    The audio stream containing the speech to be transcribed
    """


    # @ApiMember(Description="Optional client-provided identifier for the request")
    ref_id: Optional[str] = None
    """
    Optional client-provided identifier for the request
    """


    # @ApiMember(Description="Tag to identify the request")
    tag: Optional[str] = None
    """
    Tag to identify the request
    """

Python SpeechToText DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .other suffix or ?format=other

HTTP + OTHER

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /jsonl/reply/SpeechToText HTTP/1.1 
Host: test.servicestack.net 
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length

{"audio":"String","refId":"String","tag":"String"}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length

{"results":[{"text":"String"}],"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}