# sound-streamlit
**sound-streamlit is a custom widget for working with audio built into streamlit.
You only need to import one class that will allow you to record or load audio.
Any audio format is supported, and in the parameters you can set the sample rate,
minimum or maximum audio length and much more.
Ask any questions. I will be very grateful if you rate the repository ⭐️**
## Installation & setup
### 1. Install widget from PyPI
```shell
pip install sound-streamlit
```
### 2. Make sure that you have the C++ ffmpeg library installed on your computer.
<br>Its absence will lead to an [error](https://stackoverflow.com/questions/62470863/ffmpeg-command-not-found-but-pip-list-shows-ffmpeg).<br>
If you are not sure that you have it, then run the command below (only for Unix)
```shell
sudo apt install ffmpeg
```
## How to use?
### import package with widget
```python
from soundlit import AudioWidget
```
### initialize component
```python
# Custom streamlit component for audio recording and uploading
widget = AudioWidget()
# You can see params of AudioWidget belove:
# min_duration: minimum duration of audio file (By default: 0 seconds)
# max_duration: maximum duration of audio file (By default: 60_000 seconds)
# available_formats: audio files with which formats available for uploading
# convert_to: what format to convert an audio file into if it needs to be converted (By default .wav)
# execlude_convert: audio files with which formats do not require conversion to a supported format
# sample_rate: sampling rate to which the audio file will be resampled
# mono: convert waveform to mono format with one channel if True else load 2 channels
```
### use only recorder
```python
audio = widget.record_audio()
```
### or only uploader for all audio formats
```python
audio = widget.load_audio()
```
### and finally you can use the whole widget
```python
audio = widget.get_audio()
```
## How change recoder style?
### 1. Install [node](https://nodejs.org/en/download) >= 16
### 2. Go to the cloned project directory, then to the 'soundlit/recorder' package, and finally to the fronted folder.
```shell
cd ./soundlit/recorder/frontend
```
### 3. Install all fronted dependencies
```npm
npm i
```
### 4. Set Node options for legacy support
#### on Unix-like (Linux, macOS, Git bash, etc.)
```shell
export NODE_OPTIONS=--openssl-legacy-provider
```
#### on Windows command prompt
```shell
set NODE_OPTIONS=--openssl-legacy-provider
```
#### on PowerShell
```shell
$env:NODE_OPTIONS = "--openssl-legacy-provider"
```
### 5. Change component style
#### go to the file StreamlitAudioRecorder.tsx at the path below in any text editor
```shell
cd ./soundlit/recorder/frontend/src/StreamlitAudioRecorder.tsx
```
#### and change the styles that start from line 59
```html
<AudioReactRecorder
state={recordState}
onStop={this.onStop_audio}
type='audio/wav'
backgroundColor='#000000'
foregroundColor='#6633CC'
canvasWidth={450}
canvasHeight={100}
/>
```
### 6. Remove current frontend build
```shell
rm -rf ./soundlit/recorder/frontend/build
```
### 7. Build new fronted comnponent
```shell
npm run build
```
### 8. Remove all dependencies unless you no longer need to change the style
#### on Unix-like (Linux, macOS)
```shell
rm -rf node_modules
```
#### on Windows
```shell
npm i -g rm
rm -rf node_modules
```
Raw data
{
"_id": null,
"home_page": "https://github.com/YeaMerci/sound-streamlit",
"name": "sound-streamlit",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "",
"keywords": "waveform,converting,streamlit-audio-recorder,recorder,audio,streamlit,streamlit-component",
"author": "YeaMerci",
"author_email": "entertomerci@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/f5/62/dc13edf65728b20b70a953dbb80c49f472d06316d4bd9c0a75e0994531a3/sound-streamlit-0.1.7.tar.gz",
"platform": null,
"description": "# sound-streamlit\n\n**sound-streamlit is a custom widget for working with audio built into streamlit. \nYou only need to import one class that will allow you to record or load audio. \nAny audio format is supported, and in the parameters you can set the sample rate, \nminimum or maximum audio length and much more.\nAsk any questions. I will be very grateful if you rate the repository \u2b50\ufe0f**\n\n\n## Installation & setup\n### 1. Install widget from PyPI\n```shell\npip install sound-streamlit\n```\n### 2. Make sure that you have the C++ ffmpeg library installed on your computer. \n<br>Its absence will lead to an [error](https://stackoverflow.com/questions/62470863/ffmpeg-command-not-found-but-pip-list-shows-ffmpeg).<br> \nIf you are not sure that you have it, then run the command below (only for Unix)\n```shell\nsudo apt install ffmpeg\n```\n\n## How to use?\n### import package with widget\n```python\nfrom soundlit import AudioWidget\n```\n\n### initialize component\n```python\n# Custom streamlit component for audio recording and uploading\nwidget = AudioWidget() \n\n# You can see params of AudioWidget belove:\n# min_duration: minimum duration of audio file (By default: 0 seconds)\n# max_duration: maximum duration of audio file (By default: 60_000 seconds)\n# available_formats: audio files with which formats available for uploading\n# convert_to: what format to convert an audio file into if it needs to be converted (By default .wav)\n# execlude_convert: audio files with which formats do not require conversion to a supported format\n# sample_rate: sampling rate to which the audio file will be resampled\n# mono: convert waveform to mono format with one channel if True else load 2 channels\n```\n\n### use only recorder \n```python\naudio = widget.record_audio()\n```\n\n### or only uploader for all audio formats\n```python\naudio = widget.load_audio()\n```\n\n### and finally you can use the whole widget\n```python\naudio = widget.get_audio()\n```\n\n## How change recoder style?\n### 1. Install [node](https://nodejs.org/en/download) >= 16\n### 2. Go to the cloned project directory, then to the 'soundlit/recorder' package, and finally to the fronted folder.\n```shell\ncd ./soundlit/recorder/frontend\n```\n### 3. Install all fronted dependencies \n```npm\nnpm i\n```\n### 4. Set Node options for legacy support \n#### on Unix-like (Linux, macOS, Git bash, etc.)\n```shell\nexport NODE_OPTIONS=--openssl-legacy-provider\n```\n\n#### on Windows command prompt\n```shell\nset NODE_OPTIONS=--openssl-legacy-provider\n```\n\n#### on PowerShell\n```shell\n$env:NODE_OPTIONS = \"--openssl-legacy-provider\"\n```\n\n### 5. Change component style\n#### go to the file StreamlitAudioRecorder.tsx at the path below in any text editor\n```shell\ncd ./soundlit/recorder/frontend/src/StreamlitAudioRecorder.tsx\n```\n#### and change the styles that start from line 59\n```html\n<AudioReactRecorder\nstate={recordState}\nonStop={this.onStop_audio}\ntype='audio/wav'\nbackgroundColor='#000000'\nforegroundColor='#6633CC'\ncanvasWidth={450}\ncanvasHeight={100}\n/>\n```\n\n### 6. Remove current frontend build\n```shell\nrm -rf ./soundlit/recorder/frontend/build\n```\n\n### 7. Build new fronted comnponent\n```shell\nnpm run build\n```\n\n### 8. Remove all dependencies unless you no longer need to change the style\n#### on Unix-like (Linux, macOS)\n```shell \nrm -rf node_modules\n``` \n#### on Windows\n```shell\nnpm i -g rm\nrm -rf node_modules\n```\n",
"bugtrack_url": null,
"license": "",
"summary": "The package contains a ready-to-use streamlit widget for downloading or recording audio. There is support for most audio formats.",
"version": "0.1.7",
"project_urls": {
"Homepage": "https://github.com/YeaMerci/sound-streamlit"
},
"split_keywords": [
"waveform",
"converting",
"streamlit-audio-recorder",
"recorder",
"audio",
"streamlit",
"streamlit-component"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f562dc13edf65728b20b70a953dbb80c49f472d06316d4bd9c0a75e0994531a3",
"md5": "2ca9e2ee8709d6f5934f1516f36134d9",
"sha256": "897499949387d21382074dbae23da7e049ed53d33e2c64e69764cb2f3e5a659f"
},
"downloads": -1,
"filename": "sound-streamlit-0.1.7.tar.gz",
"has_sig": false,
"md5_digest": "2ca9e2ee8709d6f5934f1516f36134d9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 875874,
"upload_time": "2023-12-16T18:30:08",
"upload_time_iso_8601": "2023-12-16T18:30:08.487474Z",
"url": "https://files.pythonhosted.org/packages/f5/62/dc13edf65728b20b70a953dbb80c49f472d06316d4bd9c0a75e0994531a3/sound-streamlit-0.1.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-16 18:30:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "YeaMerci",
"github_project": "sound-streamlit",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "sound-streamlit"
}