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 | 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; |
12 class Error extends bindings.MojoEnum { | 13 class Error extends bindings.MojoEnum { |
13 static const Error networkTimeout = const Error._(1); | 14 static const Error networkTimeout = const Error._(1); |
14 static const Error network = const Error._(2); | 15 static const Error network = const Error._(2); |
15 static const Error audio = const Error._(3); | 16 static const Error audio = const Error._(3); |
16 static const Error server = const Error._(4); | 17 static const Error server = const Error._(4); |
17 static const Error client = const Error._(5); | 18 static const Error client = const Error._(5); |
18 static const Error speechTimeout = const Error._(6); | 19 static const Error speechTimeout = const Error._(6); |
19 static const Error noMatch = const Error._(7); | 20 static const Error noMatch = const Error._(7); |
20 static const Error recognizerBusy = const Error._(8); | 21 static const Error recognizerBusy = const Error._(8); |
21 static const Error insufficientPermissions = const Error._(9); | 22 static const Error insufficientPermissions = const Error._(9); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 case client: | 96 case client: |
96 return 'Error.client'; | 97 return 'Error.client'; |
97 case speechTimeout: | 98 case speechTimeout: |
98 return 'Error.speechTimeout'; | 99 return 'Error.speechTimeout'; |
99 case noMatch: | 100 case noMatch: |
100 return 'Error.noMatch'; | 101 return 'Error.noMatch'; |
101 case recognizerBusy: | 102 case recognizerBusy: |
102 return 'Error.recognizerBusy'; | 103 return 'Error.recognizerBusy'; |
103 case insufficientPermissions: | 104 case insufficientPermissions: |
104 return 'Error.insufficientPermissions'; | 105 return 'Error.insufficientPermissions'; |
| 106 default: |
| 107 return null; |
105 } | 108 } |
106 } | 109 } |
107 | 110 |
108 int toJson() => mojoEnumValue; | 111 int toJson() => mojoEnumValue; |
109 } | 112 } |
110 | 113 |
111 | 114 |
112 | 115 |
| 116 |
| 117 |
113 class UtteranceCandidate extends bindings.Struct { | 118 class UtteranceCandidate extends bindings.Struct { |
114 static const List<bindings.StructDataHeader> kVersions = const [ | 119 static const List<bindings.StructDataHeader> kVersions = const [ |
115 const bindings.StructDataHeader(24, 0) | 120 const bindings.StructDataHeader(24, 0) |
116 ]; | 121 ]; |
117 String text = null; | 122 String text = null; |
118 double confidenceScore = 0.0; | 123 double confidenceScore = 0.0; |
119 | 124 |
120 UtteranceCandidate() : super(kVersions.last.size); | 125 UtteranceCandidate() : super(kVersions.last.size); |
121 | 126 |
122 static UtteranceCandidate deserialize(bindings.Message message) { | 127 static UtteranceCandidate deserialize(bindings.Message message) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 184 |
180 Map toJson() { | 185 Map toJson() { |
181 Map map = new Map(); | 186 Map map = new Map(); |
182 map["text"] = text; | 187 map["text"] = text; |
183 map["confidenceScore"] = confidenceScore; | 188 map["confidenceScore"] = confidenceScore; |
184 return map; | 189 return map; |
185 } | 190 } |
186 } | 191 } |
187 | 192 |
188 | 193 |
| 194 |
| 195 |
189 class _SpeechRecognizerServiceListenParams extends bindings.Struct { | 196 class _SpeechRecognizerServiceListenParams extends bindings.Struct { |
190 static const List<bindings.StructDataHeader> kVersions = const [ | 197 static const List<bindings.StructDataHeader> kVersions = const [ |
191 const bindings.StructDataHeader(8, 0) | 198 const bindings.StructDataHeader(8, 0) |
192 ]; | 199 ]; |
193 | 200 |
194 _SpeechRecognizerServiceListenParams() : super(kVersions.last.size); | 201 _SpeechRecognizerServiceListenParams() : super(kVersions.last.size); |
195 | 202 |
196 static _SpeechRecognizerServiceListenParams deserialize(bindings.Message messa
ge) { | 203 static _SpeechRecognizerServiceListenParams deserialize(bindings.Message messa
ge) { |
197 var decoder = new bindings.Decoder(message); | 204 var decoder = new bindings.Decoder(message); |
198 var result = decode(decoder); | 205 var result = decode(decoder); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 return "_SpeechRecognizerServiceListenParams("")"; | 244 return "_SpeechRecognizerServiceListenParams("")"; |
238 } | 245 } |
239 | 246 |
240 Map toJson() { | 247 Map toJson() { |
241 Map map = new Map(); | 248 Map map = new Map(); |
242 return map; | 249 return map; |
243 } | 250 } |
244 } | 251 } |
245 | 252 |
246 | 253 |
| 254 |
| 255 |
247 class SpeechRecognizerServiceListenResponseParams extends bindings.Struct { | 256 class SpeechRecognizerServiceListenResponseParams extends bindings.Struct { |
248 static const List<bindings.StructDataHeader> kVersions = const [ | 257 static const List<bindings.StructDataHeader> kVersions = const [ |
249 const bindings.StructDataHeader(24, 0) | 258 const bindings.StructDataHeader(24, 0) |
250 ]; | 259 ]; |
251 ResultOrError resultOrError = null; | 260 ResultOrError resultOrError = null; |
252 | 261 |
253 SpeechRecognizerServiceListenResponseParams() : super(kVersions.last.size); | 262 SpeechRecognizerServiceListenResponseParams() : super(kVersions.last.size); |
254 | 263 |
255 static SpeechRecognizerServiceListenResponseParams deserialize(bindings.Messag
e message) { | 264 static SpeechRecognizerServiceListenResponseParams deserialize(bindings.Messag
e message) { |
256 var decoder = new bindings.Decoder(message); | 265 var decoder = new bindings.Decoder(message); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 } | 317 } |
309 | 318 |
310 Map toJson() { | 319 Map toJson() { |
311 Map map = new Map(); | 320 Map map = new Map(); |
312 map["resultOrError"] = resultOrError; | 321 map["resultOrError"] = resultOrError; |
313 return map; | 322 return map; |
314 } | 323 } |
315 } | 324 } |
316 | 325 |
317 | 326 |
| 327 |
| 328 |
318 class _SpeechRecognizerServiceStopListeningParams extends bindings.Struct { | 329 class _SpeechRecognizerServiceStopListeningParams extends bindings.Struct { |
319 static const List<bindings.StructDataHeader> kVersions = const [ | 330 static const List<bindings.StructDataHeader> kVersions = const [ |
320 const bindings.StructDataHeader(8, 0) | 331 const bindings.StructDataHeader(8, 0) |
321 ]; | 332 ]; |
322 | 333 |
323 _SpeechRecognizerServiceStopListeningParams() : super(kVersions.last.size); | 334 _SpeechRecognizerServiceStopListeningParams() : super(kVersions.last.size); |
324 | 335 |
325 static _SpeechRecognizerServiceStopListeningParams deserialize(bindings.Messag
e message) { | 336 static _SpeechRecognizerServiceStopListeningParams deserialize(bindings.Messag
e message) { |
326 var decoder = new bindings.Decoder(message); | 337 var decoder = new bindings.Decoder(message); |
327 var result = decode(decoder); | 338 var result = decode(decoder); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 } | 378 } |
368 | 379 |
369 Map toJson() { | 380 Map toJson() { |
370 Map map = new Map(); | 381 Map map = new Map(); |
371 return map; | 382 return map; |
372 } | 383 } |
373 } | 384 } |
374 | 385 |
375 | 386 |
376 | 387 |
| 388 |
| 389 |
377 enum ResultOrErrorTag { | 390 enum ResultOrErrorTag { |
378 errorCode, | 391 errorCode, |
379 results, | 392 results, |
380 unknown | 393 unknown |
381 } | 394 } |
382 | 395 |
383 class ResultOrError extends bindings.Union { | 396 class ResultOrError extends bindings.Union { |
384 static final _tag_to_int = const { | 397 static final _tag_to_int = const { |
385 ResultOrErrorTag.errorCode: 0, | 398 ResultOrErrorTag.errorCode: 0, |
386 ResultOrErrorTag.results: 1, | 399 ResultOrErrorTag.results: 1, |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 case ResultOrErrorTag.results: | 504 case ResultOrErrorTag.results: |
492 result += "results"; | 505 result += "results"; |
493 break; | 506 break; |
494 default: | 507 default: |
495 result += "unknown"; | 508 result += "unknown"; |
496 } | 509 } |
497 result += ": $_data)"; | 510 result += ": $_data)"; |
498 return result; | 511 return result; |
499 } | 512 } |
500 } | 513 } |
| 514 |
| 515 |
| 516 |
501 const int _SpeechRecognizerService_listenName = 0; | 517 const int _SpeechRecognizerService_listenName = 0; |
502 const int _SpeechRecognizerService_stopListeningName = 1; | 518 const int _SpeechRecognizerService_stopListeningName = 1; |
503 | 519 |
| 520 |
| 521 |
| 522 class _SpeechRecognizerServiceServiceDescription implements service_describer.Se
rviceDescription { |
| 523 dynamic getTopLevelInterface([Function responseFactory = null]) => null; |
| 524 |
| 525 dynamic getTypeDefinition(String typeKey, [Function responseFactory = null]) =
> |
| 526 null; |
| 527 |
| 528 dynamic getAllTypeDefinitions([Function responseFactory = null]) => 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 |
| 760 |
OLD | NEW |