Skip to content

Commit 220e630

Browse files
authored
Adding option to import urls via CLI (#1003)
1 parent 6c9d379 commit 220e630

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

buzz/cli.py

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import enum
22
import sys
33
import typing
4+
import urllib.parse
45

56
from PyQt6.QtCore import QCommandLineParser, QCommandLineOption
67

@@ -44,6 +45,9 @@ def parse_command_line(app: Application):
4445
print(parser.helpText())
4546
sys.exit(1)
4647

48+
def is_url(path: str) -> bool:
49+
parsed = urllib.parse.urlparse(path)
50+
return all([parsed.scheme, parsed.netloc])
4751

4852
def parse(app: Application, parser: QCommandLineParser):
4953
parser.addPositionalArgument("<command>", "One of the following commands:\n- add")
@@ -203,14 +207,20 @@ def parse(app: Application, parser: QCommandLineParser):
203207
word_level_timings=word_timestamps,
204208
openai_access_token=openai_access_token,
205209
)
206-
file_transcription_options = FileTranscriptionOptions(
207-
file_paths=file_paths,
208-
output_formats=output_formats,
209-
)
210210

211211
for file_path in file_paths:
212+
path_is_url = is_url(file_path)
213+
214+
file_transcription_options = FileTranscriptionOptions(
215+
file_paths=[file_path] if not path_is_url else None,
216+
url=file_path if path_is_url else None,
217+
output_formats=output_formats,
218+
)
219+
212220
transcription_task = FileTranscriptionTask(
213-
file_path=file_path,
221+
file_path=file_path if not path_is_url else None,
222+
url=file_path if path_is_url else None,
223+
source=FileTranscriptionTask.Source.FILE_IMPORT if not path_is_url else FileTranscriptionTask.Source.URL_IMPORT,
214224
model_path=model_path,
215225
transcription_options=transcription_options,
216226
file_transcription_options=file_transcription_options,

docs/docs/cli.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ sidebar_position: 5
1010
Start a new transcription task.
1111

1212
```
13-
Usage: buzz add [options] [file file file...]
13+
Usage: buzz add [options] [file url file...]
1414
1515
Options:
1616
-t, --task <task> The task to perform. Allowed: translate,
@@ -60,7 +60,7 @@ Options:
6060
(Yiddish), yo (Yoruba), zh (Chinese). Leave
6161
empty to detect language.
6262
-p, --prompt <prompt> Initial prompt.
63-
-wt, --word-timestamps Generate word-level timestamps.
63+
-wt, --word-timestamps Generate word-level timestamps. (available since 1.2.0)
6464
--openai-token <token> OpenAI access token. Use only when
6565
--model-type is openaiapi. Defaults to your
6666
previously saved access token, if one exists.
@@ -73,7 +73,7 @@ Options:
7373
-v, --version Displays version information.
7474
7575
Arguments:
76-
files Input file paths
76+
files or urls Input file paths or urls. Url import availalbe since 1.2.0.
7777
```
7878

7979
**Examples**:

docs/docs/faq.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ title: FAQ
33
sidebar_position: 5
44
---
55

6-
1. **Where are the models stored?**
6+
#### 1. Where are the models stored?
77

88
The models are stored in `~/.cache/Buzz` (Linux), `~/Library/Caches/Buzz`
99
(Mac OS) or `%USERPROFILE%\AppData\Local\Buzz\Buzz\Cache` (Windows).
1010

1111
Paste the location in your file manager to access the models.
1212

13-
2. **What can I try if the transcription runs too slowly?**
13+
#### 2. What can I try if the transcription runs too slowly?
1414

1515
Speech recognition requires large amount of computation, so one option is to try using a lower Whisper model size or using a Whisper.cpp model to run speech recognition of your computer. If you have access to a computer with GPU that has at least 6GB of VRAM you can try using the Faster Whisper model.
1616

1717
Buzz also supports using OpenAI API to do speech recognition on a remote server. To use this feature you need to set OpenAI API key in Preferences. See [Preferences](https://chidiwilliams.github.io/buzz/docs/preferences) section for more details.
1818

19-
3. **How to record system audio?**
19+
#### 3. How to record system audio?
2020

2121
To transcribe system audio you need to configure virtual audio device and connect output from the applications you want to transcribe to this virtual speaker. After that you can select it as source in the Buzz. See [Usage](https://chidiwilliams.github.io/buzz/docs/usage/live_recording) section for more details.
2222

@@ -25,21 +25,21 @@ sidebar_position: 5
2525
- Windows - [VB CABLE](https://vb-audio.com/Cable/)
2626
- Linux - [PulseAudio Volume Control](https://wiki.ubuntu.com/record_system_sound)
2727

28-
4. **What model should I use?**
28+
#### 4. What model should I use?
2929

3030
Model size to use will depend on your hardware and use case. Smaller models will work faster but will have more inaccuracies. Larger models will be more accurate but will require more powerful hardware or longer time to transcribe.
3131

3232
When choosing among large models consider the following. "Large" is the first released older model, "Large-V2" is later updated model with better accuracy, for some languages considered the most robust and stable. "Large-V3" is the latest model with the best accuracy in many cases, but some times can hallucinate or invent words that were never in the audio. "Turbo" model tries to get a good balance between speed and accuracy. The only sure way to know what model best suits your needs is to test them all in your language.
3333

34-
5. **How to get GPU acceleration for faster transcription?**
34+
#### 5. How to get GPU acceleration for faster transcription?
3535

3636
On Linux GPU acceleration is supported out of the box on Nvidia GPUs. If you still get any issues install [CUDA 12](https://developer.nvidia.com/cuda-downloads), [cuBLASS](https://developer.nvidia.com/cublas) and [cuDNN](https://developer.nvidia.com/cudnn).
3737

3838
On Windows see [this note](https://github.com/chidiwilliams/buzz/blob/main/CONTRIBUTING.md#gpu-support) on enabling CUDA GPU support.
3939

4040
For Faster whisper CUDA 12 is required, computers with older CUDA versions will use CPU.
4141

42-
6. **How to fix `Unanticipated host error[PaErrorCode-9999]`?**
42+
#### 6. How to fix `Unanticipated host error[PaErrorCode-9999]`?
4343

4444
Check if there are any system settings preventing apps from accessing the microphone.
4545

@@ -49,17 +49,17 @@ sidebar_position: 5
4949

5050
For method 2 there is no need to uninstall the antivirus, but see if you can temporarily disable it or if there are settings that may prevent Buzz from accessing the microphone.
5151

52-
7. **Can I use Buzz on a computer without internet?**
52+
#### 7. Can I use Buzz on a computer without internet?
5353

5454
Yes, Buzz can be used without internet connection if you download the necessary models on some other computer that has the internet and manually move them to the offline computer. The easiest way to find where the models are stored is to go to Help -> Preferences -> Models. Then download some model, and push "Show file location" button. This will open the folder where the models are stored. Copy the models folder to the same location on the offline computer. F.e. for Linux it is `.cache/Buzz/models` in your home directory.
5555

56-
8. **Buzz crashes, what to do?**
56+
#### 8. Buzz crashes, what to do?
5757

5858
If a model download was incomplete or corrupted, Buzz may crash. Try to delete the downloaded model files in `Help -> Preferences -> Models` and re-download them.
5959

6060
If that does not help, check the log file for errors and [report the issue](https://github.com/chidiwilliams/buzz/issues) so we can fix it. The log file is located in `~/Library/Logs/Buzz` (Mac OS) or `%USERPROFILE%\AppData\Local\Buzz\Buzz\Logs` (Windows). On Linux run the Buzz from the command line to see the relevant messages.
6161

62-
9. **Where can I get latest development version?**
62+
### 9. Where can I get latest development version?
6363

6464
Latest development version will have latest bug fixes and most recent features. If you feel a bit adventurous it is recommended to try the latest development version as they needs some testing before they get released to everybody.
6565

0 commit comments

Comments
 (0)