OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 library speech_recognizer_mojom; | 5 library speech_recognizer_mojom; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:mojo/bindings.dart' as bindings; | 9 import 'package:mojo/bindings.dart' as bindings; |
10 import 'package:mojo/core.dart' as core; | 10 import 'package:mojo/core.dart' as core; |
| 11 import 'package:mojo/mojo/bindings/types/mojom_types.mojom.dart' as mojom_types; |
| 12 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic
e_describer; |
11 | 13 |
12 class Error extends bindings.MojoEnum { | 14 class Error extends bindings.MojoEnum { |
13 static const Error networkTimeout = const Error._(1); | 15 static const Error networkTimeout = const Error._(1); |
14 static const Error network = const Error._(2); | 16 static const Error network = const Error._(2); |
15 static const Error audio = const Error._(3); | 17 static const Error audio = const Error._(3); |
16 static const Error server = const Error._(4); | 18 static const Error server = const Error._(4); |
17 static const Error client = const Error._(5); | 19 static const Error client = const Error._(5); |
18 static const Error speechTimeout = const Error._(6); | 20 static const Error speechTimeout = const Error._(6); |
19 static const Error noMatch = const Error._(7); | 21 static const Error noMatch = const Error._(7); |
20 static const Error recognizerBusy = const Error._(8); | 22 static const Error recognizerBusy = const Error._(8); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 case client: | 97 case client: |
96 return 'Error.client'; | 98 return 'Error.client'; |
97 case speechTimeout: | 99 case speechTimeout: |
98 return 'Error.speechTimeout'; | 100 return 'Error.speechTimeout'; |
99 case noMatch: | 101 case noMatch: |
100 return 'Error.noMatch'; | 102 return 'Error.noMatch'; |
101 case recognizerBusy: | 103 case recognizerBusy: |
102 return 'Error.recognizerBusy'; | 104 return 'Error.recognizerBusy'; |
103 case insufficientPermissions: | 105 case insufficientPermissions: |
104 return 'Error.insufficientPermissions'; | 106 return 'Error.insufficientPermissions'; |
| 107 default: |
| 108 return null; |
105 } | 109 } |
106 } | 110 } |
107 | 111 |
108 int toJson() => mojoEnumValue; | 112 int toJson() => mojoEnumValue; |
109 } | 113 } |
110 | 114 |
111 | 115 |
112 | 116 |
| 117 |
| 118 |
113 class UtteranceCandidate extends bindings.Struct { | 119 class UtteranceCandidate extends bindings.Struct { |
114 static const List<bindings.StructDataHeader> kVersions = const [ | 120 static const List<bindings.StructDataHeader> kVersions = const [ |
115 const bindings.StructDataHeader(24, 0) | 121 const bindings.StructDataHeader(24, 0) |
116 ]; | 122 ]; |
117 String text = null; | 123 String text = null; |
118 double confidenceScore = 0.0; | 124 double confidenceScore = 0.0; |
119 | 125 |
120 UtteranceCandidate() : super(kVersions.last.size); | 126 UtteranceCandidate() : super(kVersions.last.size); |
121 | 127 |
122 static UtteranceCandidate deserialize(bindings.Message message) { | 128 static UtteranceCandidate deserialize(bindings.Message message) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 185 |
180 Map toJson() { | 186 Map toJson() { |
181 Map map = new Map(); | 187 Map map = new Map(); |
182 map["text"] = text; | 188 map["text"] = text; |
183 map["confidenceScore"] = confidenceScore; | 189 map["confidenceScore"] = confidenceScore; |
184 return map; | 190 return map; |
185 } | 191 } |
186 } | 192 } |
187 | 193 |
188 | 194 |
| 195 |
| 196 |
189 class _SpeechRecognizerServiceListenParams extends bindings.Struct { | 197 class _SpeechRecognizerServiceListenParams extends bindings.Struct { |
190 static const List<bindings.StructDataHeader> kVersions = const [ | 198 static const List<bindings.StructDataHeader> kVersions = const [ |
191 const bindings.StructDataHeader(8, 0) | 199 const bindings.StructDataHeader(8, 0) |
192 ]; | 200 ]; |
193 | 201 |
194 _SpeechRecognizerServiceListenParams() : super(kVersions.last.size); | 202 _SpeechRecognizerServiceListenParams() : super(kVersions.last.size); |
195 | 203 |
196 static _SpeechRecognizerServiceListenParams deserialize(bindings.Message messa
ge) { | 204 static _SpeechRecognizerServiceListenParams deserialize(bindings.Message messa
ge) { |
197 var decoder = new bindings.Decoder(message); | 205 var decoder = new bindings.Decoder(message); |
198 var result = decode(decoder); | 206 var result = decode(decoder); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 return "_SpeechRecognizerServiceListenParams("")"; | 245 return "_SpeechRecognizerServiceListenParams("")"; |
238 } | 246 } |
239 | 247 |
240 Map toJson() { | 248 Map toJson() { |
241 Map map = new Map(); | 249 Map map = new Map(); |
242 return map; | 250 return map; |
243 } | 251 } |
244 } | 252 } |
245 | 253 |
246 | 254 |
| 255 |
| 256 |
247 class SpeechRecognizerServiceListenResponseParams extends bindings.Struct { | 257 class SpeechRecognizerServiceListenResponseParams extends bindings.Struct { |
248 static const List<bindings.StructDataHeader> kVersions = const [ | 258 static const List<bindings.StructDataHeader> kVersions = const [ |
249 const bindings.StructDataHeader(24, 0) | 259 const bindings.StructDataHeader(24, 0) |
250 ]; | 260 ]; |
251 ResultOrError resultOrError = null; | 261 ResultOrError resultOrError = null; |
252 | 262 |
253 SpeechRecognizerServiceListenResponseParams() : super(kVersions.last.size); | 263 SpeechRecognizerServiceListenResponseParams() : super(kVersions.last.size); |
254 | 264 |
255 static SpeechRecognizerServiceListenResponseParams deserialize(bindings.Messag
e message) { | 265 static SpeechRecognizerServiceListenResponseParams deserialize(bindings.Messag
e message) { |
256 var decoder = new bindings.Decoder(message); | 266 var decoder = new bindings.Decoder(message); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 } | 318 } |
309 | 319 |
310 Map toJson() { | 320 Map toJson() { |
311 Map map = new Map(); | 321 Map map = new Map(); |
312 map["resultOrError"] = resultOrError; | 322 map["resultOrError"] = resultOrError; |
313 return map; | 323 return map; |
314 } | 324 } |
315 } | 325 } |
316 | 326 |
317 | 327 |
| 328 |
| 329 |
318 class _SpeechRecognizerServiceStopListeningParams extends bindings.Struct { | 330 class _SpeechRecognizerServiceStopListeningParams extends bindings.Struct { |
319 static const List<bindings.StructDataHeader> kVersions = const [ | 331 static const List<bindings.StructDataHeader> kVersions = const [ |
320 const bindings.StructDataHeader(8, 0) | 332 const bindings.StructDataHeader(8, 0) |
321 ]; | 333 ]; |
322 | 334 |
323 _SpeechRecognizerServiceStopListeningParams() : super(kVersions.last.size); | 335 _SpeechRecognizerServiceStopListeningParams() : super(kVersions.last.size); |
324 | 336 |
325 static _SpeechRecognizerServiceStopListeningParams deserialize(bindings.Messag
e message) { | 337 static _SpeechRecognizerServiceStopListeningParams deserialize(bindings.Messag
e message) { |
326 var decoder = new bindings.Decoder(message); | 338 var decoder = new bindings.Decoder(message); |
327 var result = decode(decoder); | 339 var result = decode(decoder); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 } | 379 } |
368 | 380 |
369 Map toJson() { | 381 Map toJson() { |
370 Map map = new Map(); | 382 Map map = new Map(); |
371 return map; | 383 return map; |
372 } | 384 } |
373 } | 385 } |
374 | 386 |
375 | 387 |
376 | 388 |
| 389 |
| 390 |
377 enum ResultOrErrorTag { | 391 enum ResultOrErrorTag { |
378 errorCode, | 392 errorCode, |
379 results, | 393 results, |
380 unknown | 394 unknown |
381 } | 395 } |
382 | 396 |
383 class ResultOrError extends bindings.Union { | 397 class ResultOrError extends bindings.Union { |
384 static final _tag_to_int = const { | 398 static final _tag_to_int = const { |
385 ResultOrErrorTag.errorCode: 0, | 399 ResultOrErrorTag.errorCode: 0, |
386 ResultOrErrorTag.results: 1, | 400 ResultOrErrorTag.results: 1, |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 case ResultOrErrorTag.results: | 505 case ResultOrErrorTag.results: |
492 result += "results"; | 506 result += "results"; |
493 break; | 507 break; |
494 default: | 508 default: |
495 result += "unknown"; | 509 result += "unknown"; |
496 } | 510 } |
497 result += ": $_data)"; | 511 result += ": $_data)"; |
498 return result; | 512 return result; |
499 } | 513 } |
500 } | 514 } |
| 515 |
| 516 |
| 517 |
501 const int _SpeechRecognizerService_listenName = 0; | 518 const int _SpeechRecognizerService_listenName = 0; |
502 const int _SpeechRecognizerService_stopListeningName = 1; | 519 const int _SpeechRecognizerService_stopListeningName = 1; |
503 | 520 |
| 521 |
| 522 |
| 523 class _SpeechRecognizerServiceServiceDescription implements service_describer.Se
rviceDescription { |
| 524 dynamic getTopLevelInterface([Function responseFactory]) => null; |
| 525 |
| 526 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => null; |
| 527 |
| 528 dynamic getAllTypeDefinitions([Function responseFactory]) => null; |
| 529 } |
| 530 |
504 abstract class SpeechRecognizerService { | 531 abstract class SpeechRecognizerService { |
505 static const String serviceName = "speech_recognizer::SpeechRecognizerService"
; | 532 static const String serviceName = "speech_recognizer::SpeechRecognizerService"
; |
506 dynamic listen([Function responseFactory = null]); | 533 dynamic listen([Function responseFactory = null]); |
507 void stopListening(); | 534 void stopListening(); |
508 } | 535 } |
509 | 536 |
510 | 537 |
511 class _SpeechRecognizerServiceProxyImpl extends bindings.Proxy { | 538 class _SpeechRecognizerServiceProxyImpl extends bindings.Proxy { |
512 _SpeechRecognizerServiceProxyImpl.fromEndpoint( | 539 _SpeechRecognizerServiceProxyImpl.fromEndpoint( |
513 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 540 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
514 | 541 |
515 _SpeechRecognizerServiceProxyImpl.fromHandle(core.MojoHandle handle) : | 542 _SpeechRecognizerServiceProxyImpl.fromHandle(core.MojoHandle handle) : |
516 super.fromHandle(handle); | 543 super.fromHandle(handle); |
517 | 544 |
518 _SpeechRecognizerServiceProxyImpl.unbound() : super.unbound(); | 545 _SpeechRecognizerServiceProxyImpl.unbound() : super.unbound(); |
519 | 546 |
520 static _SpeechRecognizerServiceProxyImpl newFromEndpoint( | 547 static _SpeechRecognizerServiceProxyImpl newFromEndpoint( |
521 core.MojoMessagePipeEndpoint endpoint) { | 548 core.MojoMessagePipeEndpoint endpoint) { |
522 assert(endpoint.setDescription("For _SpeechRecognizerServiceProxyImpl")); | 549 assert(endpoint.setDescription("For _SpeechRecognizerServiceProxyImpl")); |
523 return new _SpeechRecognizerServiceProxyImpl.fromEndpoint(endpoint); | 550 return new _SpeechRecognizerServiceProxyImpl.fromEndpoint(endpoint); |
524 } | 551 } |
525 | 552 |
| 553 service_describer.ServiceDescription get serviceDescription => |
| 554 new _SpeechRecognizerServiceServiceDescription(); |
| 555 |
526 void handleResponse(bindings.ServiceMessage message) { | 556 void handleResponse(bindings.ServiceMessage message) { |
527 switch (message.header.type) { | 557 switch (message.header.type) { |
528 case _SpeechRecognizerService_listenName: | 558 case _SpeechRecognizerService_listenName: |
529 var r = SpeechRecognizerServiceListenResponseParams.deserialize( | 559 var r = SpeechRecognizerServiceListenResponseParams.deserialize( |
530 message.payload); | 560 message.payload); |
531 if (!message.header.hasRequestId) { | 561 if (!message.header.hasRequestId) { |
532 proxyError("Expected a message with a valid request Id."); | 562 proxyError("Expected a message with a valid request Id."); |
533 return; | 563 return; |
534 } | 564 } |
535 Completer c = completerMap[message.header.requestId]; | 565 Completer c = completerMap[message.header.requestId]; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 assert(_impl == null); | 743 assert(_impl == null); |
714 _impl = d; | 744 _impl = d; |
715 } | 745 } |
716 | 746 |
717 String toString() { | 747 String toString() { |
718 var superString = super.toString(); | 748 var superString = super.toString(); |
719 return "SpeechRecognizerServiceStub($superString)"; | 749 return "SpeechRecognizerServiceStub($superString)"; |
720 } | 750 } |
721 | 751 |
722 int get version => 0; | 752 int get version => 0; |
| 753 |
| 754 service_describer.ServiceDescription get serviceDescription => |
| 755 new _SpeechRecognizerServiceServiceDescription(); |
723 } | 756 } |
724 | 757 |
725 | 758 |
| 759 |
OLD | NEW |