UNPKG

3.15 kBTypeScriptView Raw
1import { Observable } from 'rxjs/Observable';
2export declare type SpeechRecognitionListeningOptions = SpeechRecognitionListeningOptionsIOS | SpeechRecognitionListeningOptionsAndroid;
3export interface SpeechRecognitionListeningOptionsIOS {
4 /**
5 * used language for recognition (default `"en-US"`)
6 */
7 language?: string;
8 /**
9 * umber of return matches (default `5`)
10 */
11 matches?: number;
12 /**
13 * Allow partial results to be returned (default `false`)
14 */
15 showPartial?: boolean;
16}
17export interface SpeechRecognitionListeningOptionsAndroid {
18 /**
19 * used language for recognition (default `"en-US"`)
20 */
21 language?: string;
22 /**
23 * number of return matches (maximum number of matches)
24 */
25 matches?: number;
26 /**
27 * displayed prompt of listener popup window
28 */
29 prompt?: string;
30 /**
31 * display listener popup window with prompt (default `true`)
32 */
33 showPopup?: boolean;
34}
35/**
36 * @beta
37 * @name SpeechRecognition
38 * @description
39 * This plugin does speech recognition using cloud services
40 *
41 * @usage
42 * ```
43 * import { SpeechRecognition } from 'ionic-native';
44 *
45 * // Check feature available
46 * SpeechRecognition.isRecognitionAvailable()
47 * .then((available: boolean) => console.log(available))
48 *
49 * // Start the recognition process
50 * SpeechRecognition.startListening(options)
51 * .subscribe(
52 * (matches: Array<string>) => console.log(matches),
53 * (onerror) => console.log('error:', onerror)
54 * )
55 *
56 * // Stop the recognition process (iOS only)
57 * SpeechRecognition.stopListening()
58 *
59 * // Get the list of supported languages
60 * SpeechRecognition.getSupportedLanguages()
61 * .then(
62 * (languages: Array<string>) => console.log(languages),
63 * (error) => console.log(error)
64 * )
65 *
66 * // Check permission
67 * SpeechRecognition.hasPermission()
68 * .then((hasPermission: boolean) => console.log(hasPermission))
69 *
70 * // Request permissions
71 * SpeechRecognition.requestPermission()
72 * .then(
73 * () => console.log('Granted'),
74 * () => console.log('Denied')
75 * )
76 *
77 * ```
78 */
79export declare class SpeechRecognition {
80 /**
81 * Check feature available
82 * @return {Promise<boolean>}
83 */
84 static isRecognitionAvailable(): Promise<boolean>;
85 /**
86 * Start the recognition process
87 * @return {Promise< Array<string> >} list of recognized terms
88 */
89 static startListening(options?: SpeechRecognitionListeningOptions): Observable<Array<string>>;
90 /**
91 * Stop the recognition process
92 */
93 static stopListening(): Promise<void>;
94 /**
95 * Get the list of supported languages
96 * @return {Promise< Array<string> >} list of languages
97 */
98 static getSupportedLanguages(): Promise<Array<string>>;
99 /**
100 * Check permission
101 * @return {Promise<boolean>} has permission
102 */
103 static hasPermission(): Promise<boolean>;
104 /**
105 * Request permissions
106 * @return {Promise<void>}
107 */
108 static requestPermission(): Promise<void>;
109}