"src/vscode:/vscode.git/clone" did not exist on "65788e46edfb60a31782a2bda0ba01f594359785"
Commit 91b05e2e authored by moto's avatar moto Committed by Facebook GitHub Bot
Browse files

Follow-up on audio playback function (#3051)

Summary:
- Add documentation
- Tweak docsrting
- Fix import

Pull Request resolved: https://github.com/pytorch/audio/pull/3051

Reviewed By: weiwangmeta, atalman, nateanl

Differential Revision: D43166081

Pulled By: mthrok

fbshipit-source-id: 7d77aa34a6318a64824626cff8372f8b9aebf6f9
parent 70acff7a
...@@ -32,6 +32,8 @@ Properties ...@@ -32,6 +32,8 @@ Properties
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{%- if members %}
Methods Methods
------- -------
...@@ -46,6 +48,7 @@ Methods ...@@ -46,6 +48,7 @@ Methods
{%- endif %} {%- endif %}
{%- endfor %} {%- endfor %}
{%- endif %}
{%- if name == "StreamReader" %} {%- if name == "StreamReader" %}
......
...@@ -12,6 +12,7 @@ torchaudio.io ...@@ -12,6 +12,7 @@ torchaudio.io
StreamReader StreamReader
StreamWriter StreamWriter
play_audio
.. rubric:: Tutorials using ``torchaudio.io`` .. rubric:: Tutorials using ``torchaudio.io``
......
from ._playback import play_audio
from ._stream_reader import StreamReader from ._stream_reader import StreamReader
from ._stream_writer import StreamWriter from ._stream_writer import StreamWriter
......
...@@ -4,7 +4,6 @@ from typing import Optional ...@@ -4,7 +4,6 @@ from typing import Optional
import torch import torch
import torchaudio import torchaudio
from torchaudio.io import StreamWriter
dict_format = { dict_format = {
torch.uint8: "u8", torch.uint8: "u8",
...@@ -23,8 +22,13 @@ def play_audio( ...@@ -23,8 +22,13 @@ def play_audio(
device: Optional[str] = None, device: Optional[str] = None,
) -> None: ) -> None:
"""Plays audio through specified or available output device. """Plays audio through specified or available output device.
This function is currently only supported on MacOS, which has access
to "audiotoolbox" output device that can play up to two audio channels. .. warning::
This function is currently only supported on MacOS, and requires
libavdevice (FFmpeg) with ``audiotoolbox`` output device.
.. note::
This function can play up to two audio channels.
Args: Args:
waveform: Tensor containing the audio to play. waveform: Tensor containing the audio to play.
...@@ -57,7 +61,7 @@ def play_audio( ...@@ -57,7 +61,7 @@ def play_audio(
) )
# Write to speaker device # Write to speaker device
s = StreamWriter(dst=path, format=device) s = torchaudio.io.StreamWriter(dst=path, format=device)
s.add_audio_stream(sample_rate, num_channels, format=format) s.add_audio_stream(sample_rate, num_channels, format=format)
# write audio to the device # write audio to the device
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment