1SPEAKER APP
2===========
3
4![logo](../images/speaker_screenshot.png){ width=400 height=320 }
5
6The Speaker app is virtual Bluetooth speaker (A2DP sink).
7The app runs as a command-line executable, but also offers an optional simple
8web-browser-based user interface.
9
10# General Usage
11You can invoke the app either as `bumble-speaker` when installed as command
12from `pip`, or `python3 apps/speaker/speaker.py` when running from a source
13distribution.
14
15```
16Usage: speaker.py [OPTIONS] TRANSPORT
17
18  Run the speaker.
19
20Options:
21  --codec [sbc|aac]          [default: aac]
22  --discover                 Discover remote endpoints once connected
23  --output NAME              Send audio to this named output (may be used more
24                             than once for multiple outputs)
25  --ui-port HTTP_PORT        HTTP port for the UI server  [default: 7654]
26  --connect ADDRESS_OR_NAME  Address or name to connect to
27  --device-config FILENAME   Device configuration file
28  --help                     Show this message and exit.
29```
30
31# Connection
32By default, the virtual speaker will wait for another device (like a phone or
33computer) to connect to it (and possibly pair). Alternatively, the speaker can
34be told to initiate a connection to a remote device, using the `--connect`
35option.
36
37# Outputs
38The speaker can have one or more outputs. By default, the only output is a text
39display on the console, as well as a browser-based user interface if connected.
40In addition, a file output can be used, in which case the received audio data is
41saved to a specified file.
42Finally, if the host computer on which your are running the application has `ffplay`
43as an available command line executable, the `@ffplay` output can be selected, in
44which case the received audio will be played on the computer's builtin speakers via
45a pipe to `ffplay`. (see the [ffplay documentation](https://www.ffmpeg.org/ffplay.html)
46for details)
47
48# Web User Interface
49When the speaker app starts, it prints out on the console the local URL at which you
50may point a browser (Chrome recommended for full functionality). The console line
51specifying the local UI URL will look like:
52```
53UI HTTP server at http://127.0.0.1:7654
54```
55
56By default, the web UI will show the status of the connection, as well as a realtime
57graph of the received audio bandwidth.
58In order to also hear the received audio, you need to click the `Audio on` button
59(this is due to the fact that most browsers will require some user interface with the
60page before granting access to the audio output APIs).
61
62# Examples
63
64In the following examples, we use a single USB Bluetooth controllers `usb:0`. Other
65transports can be used of course.
66
67!!! example "Start the speaker and wait for a connection"
68    ```
69    $ bumble-speaker usb:0
70    ```
71
72!!! example "Start the speaker and save the AAC audio to a file named `audio.aac`."
73    ```
74    $ bumble-speaker --output audio.aac usb:0
75    ```
76
77!!! example "Start the speaker and save the SBC audio to a file named `audio.sbc`."
78    ```
79    $ bumble-speaker --codec sbc --output audio.sbc usb:0
80    ```
81
82!!! example "Start the speaker and connect it to a phone at address `B8:7B:C5:05:57:ED`."
83    ```
84    $ bumble-speaker --connect B8:7B:C5:05:57:ED usb:0
85    ```
86
87