Merge pull request #8 from pathintegral-institute/rong/tech-150-add-kwarg
make pydub an optional import
This commit is contained in:
commit
f9510656e0
3 changed files with 18 additions and 5 deletions
|
|
@ -30,6 +30,12 @@ pip install git+https://github.com/pathintegral-institute/markitup.git@main#subd
|
||||||
uv add git+https://github.com/pathintegral-institute/markitup.git@main#subdirectory=packages/markitup
|
uv add git+https://github.com/pathintegral-institute/markitup.git@main#subdirectory=packages/markitup
|
||||||
```
|
```
|
||||||
|
|
||||||
|
To use audio transciption using `pydub`, install `markitup[audio]`:
|
||||||
|
```bash
|
||||||
|
uv add "git+https://github.com/pathintegral-institute/markitup.git@main#subdirectory=packages/markitup[audio]"
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
```python
|
```python
|
||||||
from markitup.converter_utils.utils import read_files_to_bytestreams
|
from markitup.converter_utils.utils import read_files_to_bytestreams
|
||||||
|
|
|
||||||
|
|
@ -34,13 +34,22 @@ dependencies = [
|
||||||
"pandas",
|
"pandas",
|
||||||
"lxml",
|
"lxml",
|
||||||
"olefile",
|
"olefile",
|
||||||
"pydub",
|
# "pydub", <- Removed from here
|
||||||
"SpeechRecognition",
|
"SpeechRecognition",
|
||||||
"pymupdf>=1.25.5",
|
"pymupdf>=1.25.5",
|
||||||
"openpyxl>=3.1.5",
|
"openpyxl>=3.1.5",
|
||||||
"xlrd>=2.0.1",
|
"xlrd>=2.0.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[project.optional-dependencies]
|
||||||
|
audio = [
|
||||||
|
"pydub",
|
||||||
|
]
|
||||||
|
# Optional: You may want to create an 'all' extra that includes all optional dependencies
|
||||||
|
all = [
|
||||||
|
"pydub",
|
||||||
|
]
|
||||||
|
|
||||||
[tool.hatch.version]
|
[tool.hatch.version]
|
||||||
path = "src/markitup/__about__.py"
|
path = "src/markitup/__about__.py"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
import os
|
import os
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from markitup._schemas import StreamInfo
|
|
||||||
import magic
|
|
||||||
import speech_recognition as sr
|
import speech_recognition as sr
|
||||||
import pydub
|
|
||||||
import io
|
import io
|
||||||
from typing import BinaryIO
|
from typing import BinaryIO
|
||||||
|
|
||||||
|
|
@ -47,6 +44,7 @@ def transcribe_audio(file_stream: BinaryIO, *, magic_type: str = "audio/mpeg") -
|
||||||
|
|
||||||
match audio_format:
|
match audio_format:
|
||||||
case 'mp3':
|
case 'mp3':
|
||||||
|
import pydub
|
||||||
audio_segment = pydub.AudioSegment.from_file(
|
audio_segment = pydub.AudioSegment.from_file(
|
||||||
file_stream, format=audio_format)
|
file_stream, format=audio_format)
|
||||||
audio_source = io.BytesIO()
|
audio_source = io.BytesIO()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue