Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -10,18 +10,13 @@ MODEL_NAME = 'sarvamai/shuka_v1'
|
|
10 |
SAMPLE_RATE = 16000
|
11 |
MAX_NEW_TOKENS = 256
|
12 |
|
13 |
-
# Load the
|
14 |
-
|
15 |
-
model
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
device=0 if torch.cuda.is_available() else -1,
|
21 |
-
)
|
22 |
-
return pipeline
|
23 |
-
|
24 |
-
pipe = load_pipeline()
|
25 |
|
26 |
def create_conversation_turns(prompt: str) -> List[Dict[str, str]]:
|
27 |
return [
|
@@ -45,7 +40,7 @@ def transcribe_and_respond(audio: np.ndarray) -> str:
|
|
45 |
}
|
46 |
|
47 |
# Generate response
|
48 |
-
response = pipe(inputs, max_new_tokens=MAX_NEW_TOKENS
|
49 |
|
50 |
return response
|
51 |
except Exception as e:
|
|
|
10 |
SAMPLE_RATE = 16000
|
11 |
MAX_NEW_TOKENS = 256
|
12 |
|
13 |
+
# Load the pipeline
|
14 |
+
pipe = transformers.pipeline(
|
15 |
+
model=MODEL_NAME,
|
16 |
+
trust_remote_code=True,
|
17 |
+
device=0,
|
18 |
+
torch_dtype='bfloat16'
|
19 |
+
)
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
def create_conversation_turns(prompt: str) -> List[Dict[str, str]]:
|
22 |
return [
|
|
|
40 |
}
|
41 |
|
42 |
# Generate response
|
43 |
+
response = pipe(inputs, max_new_tokens=MAX_NEW_TOKENS)
|
44 |
|
45 |
return response
|
46 |
except Exception as e:
|