Avi Drissman | d387f092 | 2022-09-14 20:51:31 | [diff] [blame] | 1 | // Copyright 2020 The Chromium Authors |
evliu | 2e5dbee4 | 2020-04-09 23:35:29 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | module media.mojom; |
| 6 | |
Andrew Moylan | 961a47f2 | 2022-06-03 04:26:36 | [diff] [blame] | 7 | import "media/mojo/mojom/audio_data.mojom"; |
Katie Dektar | 1ad8e7a | 2021-04-05 23:13:19 | [diff] [blame] | 8 | import "media/mojo/mojom/audio_parameters.mojom"; |
Katie Dektar | ca90aaa5 | 2021-03-04 21:32:16 | [diff] [blame] | 9 | import "media/mojo/mojom/audio_stream_factory.mojom"; |
evliu | 2e5dbee4 | 2020-04-09 23:35:29 | [diff] [blame] | 10 | import "media/mojo/mojom/media_types.mojom"; |
Andrew Moylan | aad6265f | 2022-06-07 03:52:56 | [diff] [blame] | 11 | import "media/mojo/mojom/speech_recognition.mojom"; |
evliu | 14d897af | 2020-07-30 22:17:21 | [diff] [blame] | 12 | import "mojo/public/mojom/base/file_path.mojom"; |
Alex Gough | 810f5db2 | 2023-11-20 21:28:04 | [diff] [blame] | 13 | import "sandbox/policy/mojom/context.mojom"; |
Alex Gough | 9e8487c | 2021-08-19 05:26:31 | [diff] [blame] | 14 | import "sandbox/policy/mojom/sandbox.mojom"; |
evliu | 2e5dbee4 | 2020-04-09 23:35:29 | [diff] [blame] | 15 | |
Andrew Moylan | 18aac03 | 2022-05-30 02:52:58 | [diff] [blame] | 16 | // Like a SpeechRecognitionContext, except it binds AudioSourceFetcher speech |
| 17 | // recognizer objects, rather than SpeechRecognitionRecognizer objects. In |
| 18 | // Chrome OS features like Dictation and Projector, every |
| 19 | // OnDeviceSpeechRecognizer can own a |
| 20 | // Remote<AudioSourceSpeechRecognitionContext>. |
Alex Gough | 810f5db2 | 2023-11-20 21:28:04 | [diff] [blame] | 21 | [RequireContext=sandbox.mojom.Context.kBrowser] |
Andrew Moylan | 18aac03 | 2022-05-30 02:52:58 | [diff] [blame] | 22 | interface AudioSourceSpeechRecognitionContext { |
Katie Dektar | ca90aaa5 | 2021-03-04 21:32:16 | [diff] [blame] | 23 | // Prepares microphone audio to be captured from within the |
| 24 | // SpeechRecognitionService process, with results passed back to the |
| 25 | // SpeechRecognitionRecognizerClient. |
Alex Gough | 810f5db2 | 2023-11-20 21:28:04 | [diff] [blame] | 26 | [AllowedContext=sandbox.mojom.Context.kBrowser] |
Katie Dektar | ca90aaa5 | 2021-03-04 21:32:16 | [diff] [blame] | 27 | BindAudioSourceFetcher( |
Andrew Moylan | 18aac03 | 2022-05-30 02:52:58 | [diff] [blame] | 28 | pending_receiver<AudioSourceFetcher> fetcher_receiver, |
| 29 | pending_remote<SpeechRecognitionRecognizerClient> client, |
| 30 | SpeechRecognitionOptions options) |
| 31 | => (bool is_multichannel_supported); |
evliu | 2e5dbee4 | 2020-04-09 23:35:29 | [diff] [blame] | 32 | }; |
| 33 | |
| 34 | // The main interface to a speech secognition service process. |
| 35 | // Used by the browser to issue top-level control requests to the service, |
| 36 | // acquired during process launch. |
Alex Gough | 810f5db2 | 2023-11-20 21:28:04 | [diff] [blame] | 37 | [ServiceSandbox=sandbox.mojom.Sandbox.kSpeechRecognition, |
| 38 | RequireContext=sandbox.mojom.Context.kBrowser] |
evliu | 2e5dbee4 | 2020-04-09 23:35:29 | [diff] [blame] | 39 | interface SpeechRecognitionService { |
Andrew Moylan | 18aac03 | 2022-05-30 02:52:58 | [diff] [blame] | 40 | // Binds a new SpeechRecognitionContext hosted in the service process. |
| 41 | BindSpeechRecognitionContext( |
| 42 | pending_receiver<SpeechRecognitionContext> context); |
| 43 | |
| 44 | // Binds a new AudioSourceSpeechRecognitionContext hosted in the service |
| 45 | // process. |
Alex Gough | 810f5db2 | 2023-11-20 21:28:04 | [diff] [blame] | 46 | [AllowedContext=sandbox.mojom.Context.kBrowser] |
Andrew Moylan | 18aac03 | 2022-05-30 02:52:58 | [diff] [blame] | 47 | BindAudioSourceSpeechRecognitionContext( |
| 48 | pending_receiver<AudioSourceSpeechRecognitionContext> context); |
evliu | 92468fa3 | 2020-06-08 21:05:57 | [diff] [blame] | 49 | |
evliu | b852832 | 2022-11-23 00:09:14 | [diff] [blame] | 50 | // Sets the file path to the Speech On-Device API (SODA) binary, the config |
| 51 | // file paths for the language packs, and the primary language name. |
| 52 | SetSodaPaths(mojo_base.mojom.FilePath binary_path, |
| 53 | map<string, mojo_base.mojom.FilePath> config_paths, |
| 54 | string primary_language_name); |
Abigail Klein | 644e5e6 | 2023-07-20 22:33:25 | [diff] [blame] | 55 | |
| 56 | // Sets various params to the Speech On-Device API (SODA) binary. |
| 57 | SetSodaParams(bool mask_offensive_words); |
Evan Liu | 7932f46 | 2023-08-03 17:13:12 | [diff] [blame] | 58 | |
| 59 | // Sets the config file paths for the language packs. Used to notify the |
| 60 | // service when new language packs are installed. |
| 61 | SetSodaConfigPaths(map<string, mojo_base.mojom.FilePath> config_paths); |
evliu | 92468fa3 | 2020-06-08 21:05:57 | [diff] [blame] | 62 | }; |
| 63 | |
Katie Dektar | ca90aaa5 | 2021-03-04 21:32:16 | [diff] [blame] | 64 | // The interface used to start and stop fetching audio from the microphone |
Alex Gough | 810f5db2 | 2023-11-20 21:28:04 | [diff] [blame] | 65 | // for speech recognition. Provided by the browser to the speech recognition |
| 66 | // service. |
| 67 | [RequireContext=sandbox.mojom.Context.kPrivilegedUtility] |
Katie Dektar | ca90aaa5 | 2021-03-04 21:32:16 | [diff] [blame] | 68 | interface AudioSourceFetcher { |
Katie Dektar | 9204339 | 2021-03-12 00:37:44 | [diff] [blame] | 69 | // Begin fetching audio. Results will be returned using the |
| 70 | // Remote<SpeechRecognitionRecognizerClient> which was passed in |
| 71 | // BindAudioSourceFetcher. |
Alex Gough | 810f5db2 | 2023-11-20 21:28:04 | [diff] [blame] | 72 | [AllowedContext=sandbox.mojom.Context.kPrivilegedUtility] |
Katie Dektar | 1ad8e7a | 2021-04-05 23:13:19 | [diff] [blame] | 73 | Start(pending_remote<AudioStreamFactory> factory, string device_id, |
| 74 | media.mojom.AudioParameters audio_parameters); |
Katie Dektar | 9204339 | 2021-03-12 00:37:44 | [diff] [blame] | 75 | |
Katie Dektar | ca90aaa5 | 2021-03-04 21:32:16 | [diff] [blame] | 76 | // Stops audio fetching. |
| 77 | Stop(); |
| 78 | }; |