harp-dev Claude Opus 5.5 commited on
Commit
9d716fe
·
verified ·
1 Parent(s): 2cccedd

Load in the worker, declare the format, and pin requirements

Browse files

Preloads the models in the worker alone, declares 24 kHz mono, cleans the README, and pins requirements. It also imports spaces plainly, since it is always installed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Files changed (3) hide show
  1. README.md +3 -4
  2. app.py +10 -21
  3. requirements.txt +9 -9
README.md CHANGED
@@ -14,6 +14,8 @@ tags:
14
  - subcategory:text-to-speech
15
  - input:text
16
  - output:audio
 
 
17
  - multilingual
18
  ---
19
 
@@ -21,7 +23,4 @@ tags:
21
 
22
  Bark is a transformer-based text-to-audio model created by Suno. Bark can generate highly realistic, multilingual speech as well as other audio - including music, background noise and simple sound effects. The model can also produce nonverbal communications like laughing, sighing and crying.
23
 
24
- - Inputs: textbox, dropdown, slider, slider
25
- - Outputs: audio
26
-
27
- Generated by the HARP model agent from a recipe.
 
14
  - subcategory:text-to-speech
15
  - input:text
16
  - output:audio
17
+ - sample-rate:24000
18
+ - channels:mono
19
  - multilingual
20
  ---
21
 
 
23
 
24
  Bark is a transformer-based text-to-audio model created by Suno. Bark can generate highly realistic, multilingual speech as well as other audio - including music, background noise and simple sound effects. The model can also produce nonverbal communications like laughing, sighing and crying.
25
 
26
+ A HARP deployment. See https://github.com/TEAMuP-dev/HARP
 
 
 
app.py CHANGED
@@ -1,21 +1,8 @@
1
  from __future__ import annotations
2
 
3
- import gradio as gr
4
- try:
5
- import spaces
6
- except ImportError: # 'spaces' is only provided by Hugging Face Spaces
7
- import types as _types
8
-
9
- def _gpu(*args, **kwargs):
10
- if len(args) == 1 and callable(args[0]) and not kwargs:
11
- return args[0]
12
-
13
- def _decorator(func):
14
- return func
15
-
16
- return _decorator
17
 
18
- spaces = _types.SimpleNamespace(GPU=_gpu)
19
 
20
  from pyharp import *
21
 
@@ -39,10 +26,6 @@ except Exception: # torch not installed / unexpected API -- nothing to patch
39
  from bark import generate_audio, preload_models, SAMPLE_RATE
40
  from scipy.io.wavfile import write as write_wav
41
  import tempfile
42
- import os
43
-
44
- # Download and load all models once
45
- preload_models()
46
 
47
 
48
  model_card = ModelCard(
@@ -52,12 +35,18 @@ model_card = ModelCard(
52
  "can generate highly realistic, multilingual speech as well as other "
53
  "audio - including music, background noise and simple sound effects. "
54
  "The model can also produce nonverbal communications like laughing, "
55
- "sighing and crying. Repository: https://github.com/suno-ai/bark"
 
56
  ),
57
  author="suno-ai",
58
- tags=[Subcategory.TEXT_TO_SPEECH, 'multilingual'],
59
  )
60
 
 
 
 
 
 
61
 
62
  def process_fn(text_prompt, history_prompt, text_temp, waveform_temp):
63
  # Checked before the GPU is reserved, so a request the model cannot take spends none of the
 
1
  from __future__ import annotations
2
 
3
+ import spaces # imported first, as ZeroGPU requires
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
+ import gradio as gr
6
 
7
  from pyharp import *
8
 
 
26
  from bark import generate_audio, preload_models, SAMPLE_RATE
27
  from scipy.io.wavfile import write as write_wav
28
  import tempfile
 
 
 
 
29
 
30
 
31
  model_card = ModelCard(
 
35
  "can generate highly realistic, multilingual speech as well as other "
36
  "audio - including music, background noise and simple sound effects. "
37
  "The model can also produce nonverbal communications like laughing, "
38
+ "sighing and crying. It writes 24 kHz mono audio. Repository: "
39
+ "https://github.com/suno-ai/bark"
40
  ),
41
  author="suno-ai",
42
+ tags=[Subcategory.TEXT_TO_SPEECH, SampleRate(SAMPLE_RATE), Channels(1), 'multilingual'],
43
  )
44
 
45
+ # pyharp runs process_fn in a worker, which imports this file as __mp_main__ and starts with the
46
+ # server, so every model is downloaded and loaded there alone
47
+ if __name__ != "__main__":
48
+ preload_models()
49
+
50
 
51
  def process_fn(text_prompt, history_prompt, text_temp, waveform_temp):
52
  # Checked before the GPU is reserved, so a request the model cannot take spends none of the
requirements.txt CHANGED
@@ -1,13 +1,13 @@
1
  git+https://github.com/TEAMuP-dev/pyharp.git@v0.4.2
2
  git+https://github.com/suno-ai/bark.git@f4f32d4cd480dfec1c245d258174bc9bde3c2148
3
- boto3
4
  encodec==0.1.1
5
- funcy
6
- huggingface-hub
7
- numpy
8
- scipy
9
- tokenizers
10
- torch
11
- tqdm
12
- transformers
13
  spaces>=0.51.1
 
1
  git+https://github.com/TEAMuP-dev/pyharp.git@v0.4.2
2
  git+https://github.com/suno-ai/bark.git@f4f32d4cd480dfec1c245d258174bc9bde3c2148
3
+ boto3==1.43.118
4
  encodec==0.1.1
5
+ funcy==2.1
6
+ huggingface-hub==1.33.0
7
+ numpy==2.2.6
8
+ scipy==1.15.3
9
+ tokenizers==0.23.3
10
+ torch==2.13.0
11
+ tqdm==4.70.1
12
+ transformers==5.20.2
13
  spaces>=0.51.1