Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,21 @@
|
|
1 |
-
|
2 |
-
from
|
3 |
-
import torch
|
4 |
-
import os
|
5 |
-
import tempfile
|
6 |
-
import soundfile as sf
|
7 |
|
8 |
-
|
9 |
-
device = 0 if torch.cuda.is_available() else -1
|
10 |
-
asr_pipeline = pipeline(model="openai/whisper-small", device=device)
|
11 |
|
12 |
-
#
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
16 |
|
17 |
-
|
18 |
-
|
|
|
|
|
19 |
|
20 |
-
#
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
outputs="text", # Output type: text (transcription)
|
25 |
-
title="Whisper Audio Transcription", # Title of the Gradio interface
|
26 |
-
description="Upload an audio file to get a transcription using OpenAI's Whisper model"
|
27 |
-
)
|
28 |
-
|
29 |
-
# Launch the Gradio interface
|
30 |
-
interface.launch()
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
from pydantic import BaseModel
|
|
|
|
|
|
|
|
|
3 |
|
4 |
+
app = FastAPI()
|
|
|
|
|
5 |
|
6 |
+
# Sample request model
|
7 |
+
class Item(BaseModel):
|
8 |
+
name: str
|
9 |
+
description: str
|
10 |
+
price: float
|
11 |
+
tax: float
|
12 |
|
13 |
+
# Basic GET endpoint
|
14 |
+
@app.get("/")
|
15 |
+
def read_root():
|
16 |
+
return {"message": "Welcome to the FastAPI app on Hugging Face Spaces!"}
|
17 |
|
18 |
+
# POST endpoint
|
19 |
+
@app.post("/items/")
|
20 |
+
def create_item(item: Item):
|
21 |
+
return {"item": item}
|
|
|
|
|
|
|
|
|
|
|
|
|
|