/
transcribe_streaming.ex
158 lines (140 loc) · 5.54 KB
/
transcribe_streaming.ex
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# WARNING: DO NOT EDIT, AUTO-GENERATED CODE!
# See https://github.com/aws-beam/aws-codegen for more details.
defmodule AWS.TranscribeStreaming do
@moduledoc """
Operations and objects for transcribing streaming speech to text.
"""
alias AWS.Client
alias AWS.Request
def metadata do
%AWS.ServiceMetadata{
abbreviation: nil,
api_version: "2017-10-26",
content_type: "application/x-amz-json-1.1",
credential_scope: nil,
endpoint_prefix: "transcribestreaming",
global?: false,
protocol: "rest-json",
service_id: "Transcribe Streaming",
signature_version: "v4",
signing_name: "transcribe",
target_prefix: nil
}
end
@doc """
Starts a bidirectional HTTP/2 stream where audio is streamed to Amazon
Transcribe Medical and the transcription results are streamed to your
application.
"""
def start_medical_stream_transcription(%Client{} = client, input, options \\ []) do
url_path = "/medical-stream-transcription"
{headers, input} =
[
{"ContentIdentificationType", "x-amzn-transcribe-content-identification-type"},
{"EnableChannelIdentification", "x-amzn-transcribe-enable-channel-identification"},
{"LanguageCode", "x-amzn-transcribe-language-code"},
{"MediaEncoding", "x-amzn-transcribe-media-encoding"},
{"MediaSampleRateHertz", "x-amzn-transcribe-sample-rate"},
{"NumberOfChannels", "x-amzn-transcribe-number-of-channels"},
{"SessionId", "x-amzn-transcribe-session-id"},
{"ShowSpeakerLabel", "x-amzn-transcribe-show-speaker-label"},
{"Specialty", "x-amzn-transcribe-specialty"},
{"Type", "x-amzn-transcribe-type"},
{"VocabularyName", "x-amzn-transcribe-vocabulary-name"}
]
|> Request.build_params(input)
query_params = []
options =
Keyword.put(
options,
:response_header_parameters,
[
{"x-amzn-transcribe-content-identification-type", "ContentIdentificationType"},
{"x-amzn-transcribe-enable-channel-identification", "EnableChannelIdentification"},
{"x-amzn-transcribe-language-code", "LanguageCode"},
{"x-amzn-transcribe-media-encoding", "MediaEncoding"},
{"x-amzn-transcribe-sample-rate", "MediaSampleRateHertz"},
{"x-amzn-transcribe-number-of-channels", "NumberOfChannels"},
{"x-amzn-request-id", "RequestId"},
{"x-amzn-transcribe-session-id", "SessionId"},
{"x-amzn-transcribe-show-speaker-label", "ShowSpeakerLabel"},
{"x-amzn-transcribe-specialty", "Specialty"},
{"x-amzn-transcribe-type", "Type"},
{"x-amzn-transcribe-vocabulary-name", "VocabularyName"}
]
)
Request.request_rest(
client,
metadata(),
:post,
url_path,
query_params,
headers,
input,
options,
nil
)
end
@doc """
Starts a bidirectional HTTP2 stream where audio is streamed to Amazon Transcribe
and the transcription results are streamed to your application.
The following are encoded as HTTP2 headers:
* x-amzn-transcribe-language-code
* x-amzn-transcribe-media-encoding
* x-amzn-transcribe-sample-rate
* x-amzn-transcribe-session-id
"""
def start_stream_transcription(%Client{} = client, input, options \\ []) do
url_path = "/stream-transcription"
{headers, input} =
[
{"EnableChannelIdentification", "x-amzn-transcribe-enable-channel-identification"},
{"EnablePartialResultsStabilization",
"x-amzn-transcribe-enable-partial-results-stabilization"},
{"LanguageCode", "x-amzn-transcribe-language-code"},
{"MediaEncoding", "x-amzn-transcribe-media-encoding"},
{"MediaSampleRateHertz", "x-amzn-transcribe-sample-rate"},
{"NumberOfChannels", "x-amzn-transcribe-number-of-channels"},
{"PartialResultsStability", "x-amzn-transcribe-partial-results-stability"},
{"SessionId", "x-amzn-transcribe-session-id"},
{"ShowSpeakerLabel", "x-amzn-transcribe-show-speaker-label"},
{"VocabularyFilterMethod", "x-amzn-transcribe-vocabulary-filter-method"},
{"VocabularyFilterName", "x-amzn-transcribe-vocabulary-filter-name"},
{"VocabularyName", "x-amzn-transcribe-vocabulary-name"}
]
|> Request.build_params(input)
query_params = []
options =
Keyword.put(
options,
:response_header_parameters,
[
{"x-amzn-transcribe-enable-channel-identification", "EnableChannelIdentification"},
{"x-amzn-transcribe-enable-partial-results-stabilization",
"EnablePartialResultsStabilization"},
{"x-amzn-transcribe-language-code", "LanguageCode"},
{"x-amzn-transcribe-media-encoding", "MediaEncoding"},
{"x-amzn-transcribe-sample-rate", "MediaSampleRateHertz"},
{"x-amzn-transcribe-number-of-channels", "NumberOfChannels"},
{"x-amzn-transcribe-partial-results-stability", "PartialResultsStability"},
{"x-amzn-request-id", "RequestId"},
{"x-amzn-transcribe-session-id", "SessionId"},
{"x-amzn-transcribe-show-speaker-label", "ShowSpeakerLabel"},
{"x-amzn-transcribe-vocabulary-filter-method", "VocabularyFilterMethod"},
{"x-amzn-transcribe-vocabulary-filter-name", "VocabularyFilterName"},
{"x-amzn-transcribe-vocabulary-name", "VocabularyName"}
]
)
Request.request_rest(
client,
metadata(),
:post,
url_path,
query_params,
headers,
input,
options,
nil
)
end
end