File size: 1,390 Bytes
76d9c4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
---
title: vessl.Audio
version: EN
---

Use the `vessl.Audio` class to log audio data. This takes the audio data and saves it as a local WAV file in the `vessl-media/audio` directory with randomly generated names.



| Parameter      | Description                                                                                                        |
| -------------- | ------------------------------------------------------------------------------------------------------------------ |
| `data_or_path` | <p>Supported types - <code>numpy.ndarray</code> : the audio data</p><p> - <code>str</code>: the audio path</p> |
| `sample_rate`  | The sample rate of the audio file. Required if the `numpy.ndarray` of audio data is provided as `data_or_path`     |
| `caption`      | Label of the given audio                                                                                           |

### `numpy.ndarray`

```python
import vessl
import soundfile as sf

audio_path = "sample.wav"
data, sample_rate = sf.read(audio_path)


# Sample rate is required if numpy.ndarray is provided 
vessl.log(
  payload={
    "test-audio": [
      vessl.Audio(data, sample_rate=sample_rate, caption="audio with data example")
    ]
  }
)
```

### `str`

```python
import vessl 

vessl.log(
  payload={
    "test-audio": [
      vessl.Audio(audio_path, caption="audio with path example")
    ]
  }
)
```