harp-dev commited on
Commit
b3b65a0
·
verified ·
1 Parent(s): a80edb6

Deploy HARP wrapper via model agent

Browse files
Files changed (5) hide show
  1. .harp/manifest.json +18 -0
  2. README.md +13 -7
  3. app.py +61 -0
  4. packages.txt +1 -0
  5. requirements.txt +6 -0
.harp/manifest.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "entry": "app.py",
3
+ "framework": "voicefixer",
4
+ "generated": true,
5
+ "io": {
6
+ "inputs": [
7
+ "audio",
8
+ "dropdown"
9
+ ],
10
+ "outputs": [
11
+ "audio"
12
+ ]
13
+ },
14
+ "repo_id": "haoheliu/voicefixer",
15
+ "source": "recipe",
16
+ "space_layout": "huggingface-gradio",
17
+ "task": "declipping"
18
+ }
README.md CHANGED
@@ -1,13 +1,19 @@
1
  ---
2
- title: Voicefixer
3
- emoji: 🏢
4
- colorFrom: red
5
- colorTo: green
6
  sdk: gradio
7
- sdk_version: 6.20.0
8
- python_version: '3.13'
9
  app_file: app.py
10
  pinned: false
 
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
1
  ---
2
+ title: "VoiceFixer"
3
+ colorFrom: indigo
4
+ colorTo: gray
 
5
  sdk: gradio
6
+ sdk_version: 5.28.0
 
7
  app_file: app.py
8
  pinned: false
9
+ license: "mit"
10
  ---
11
 
12
+ # VoiceFixer
13
+
14
+ VoiceFixer aims to restore human speech regardless how serious its degraded. It can handle noise, reverberation, low resolution (2kHz~44.1kHz) and clipping (0.1-1.0 threshold) effect within one model.
15
+
16
+ - Inputs: audio, dropdown
17
+ - Outputs: audio
18
+
19
+ Generated by the HARP model agent from a recipe.
app.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
22
+
23
+ import tempfile
24
+ from voicefixer import VoiceFixer
25
+
26
+ # Initialize VoiceFixer. It handles downloading checkpoints and setting device.
27
+ # The VoiceFixer class automatically detects and uses CUDA if available.
28
+ voicefixer_model = VoiceFixer()
29
+
30
+
31
+ model_card = ModelCard(
32
+ name="VoiceFixer",
33
+ description="VoiceFixer aims to restore human speech regardless how serious its degraded. It can handle noise, reverberation, low resolution (2kHz~44.1kHz) and clipping (0.1-1.0 threshold) effect within one model.",
34
+ author="haoheliu",
35
+ tags=["declipping", "denoise", "dereverberation", "mel", "speech", "speech-analysis", "speech-enhancement", "speech-processing", "speech-synthesis", "super-resolution", "tts", "vocoder"],
36
+ )
37
+
38
+
39
+ @spaces.GPU
40
+ def process_fn(input_audio, mode):
41
+ output_file = tempfile.NamedTemporaryFile(suffix=".wav", delete=False).name
42
+ voicefixer_model.restore(input_audio, output_file, mode=int(mode))
43
+ return output_file
44
+
45
+
46
+ with gr.Blocks() as demo:
47
+ input_components = [
48
+ gr.Audio(type="filepath", label="Input Audio").harp_required(True).set_info("Upload an audio file to be processed by VoiceFixer."),
49
+ gr.Dropdown(choices=["0", "1", "2"], value="0", label="Processing Mode", info="Select the VoiceFixer processing mode:\n0: Original Model (suggested by default)\n1: Add preprocessing module (remove higher frequency)\n2: Train mode (might work sometimes on seriously degraded real speech)"),
50
+ ]
51
+ output_components = [
52
+ gr.Audio(type="filepath", label="Fixed Audio").set_info("The enhanced audio output from VoiceFixer."),
53
+ ]
54
+ build_endpoint(
55
+ model_card=model_card,
56
+ input_components=input_components,
57
+ output_components=output_components,
58
+ process_fn=process_fn,
59
+ )
60
+
61
+ demo.queue().launch(share=True, show_error=False, pwa=True)
packages.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ ffmpeg
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ git+https://github.com/TEAMuP-dev/pyharp.git@v0.3.0
2
+ gradio>=4.0
3
+ git+https://github.com/haoheliu/voicefixer.git@main
4
+ torch>=1.7.0
5
+ librosa
6
+ torchlibrosa