Update app.py
Browse files
app.py
CHANGED
|
@@ -50,31 +50,12 @@ class FasterRCNNDetector:
|
|
| 50 |
|
| 51 |
class JarvisModels:
|
| 52 |
def __init__(self):
|
| 53 |
-
self.client1 = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
| 54 |
self.processor = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-base-960h")
|
| 55 |
self.model = Wav2Vec2ForCTC.from_pretrained("facebook/wav2vec2-base-960h")
|
| 56 |
|
| 57 |
async def generate_response(self, prompt):
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
max_new_tokens=256,
|
| 61 |
-
top_p=0.95,
|
| 62 |
-
repetition_penalty=1,
|
| 63 |
-
do_sample=True,
|
| 64 |
-
seed=42,
|
| 65 |
-
)
|
| 66 |
-
formatted_prompt = system_instructions1 + prompt + "[JARVIS]"
|
| 67 |
-
stream = self.client1.text_generation(
|
| 68 |
-
formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=True)
|
| 69 |
-
output = ""
|
| 70 |
-
for response in stream:
|
| 71 |
-
output += response.token.text
|
| 72 |
-
|
| 73 |
-
communicate = edge_tts.Communicate(output)
|
| 74 |
-
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|
| 75 |
-
tmp_path = tmp_file.name
|
| 76 |
-
communicate.save(tmp_path)
|
| 77 |
-
return tmp_path
|
| 78 |
|
| 79 |
async def transcribe_audio(self, audio_file):
|
| 80 |
input_audio, _ = torchaudio.load(audio_file)
|
|
|
|
| 50 |
|
| 51 |
class JarvisModels:
|
| 52 |
def __init__(self):
|
|
|
|
| 53 |
self.processor = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-base-960h")
|
| 54 |
self.model = Wav2Vec2ForCTC.from_pretrained("facebook/wav2vec2-base-960h")
|
| 55 |
|
| 56 |
async def generate_response(self, prompt):
|
| 57 |
+
# Anda dapat menambahkan logika untuk menghasilkan tanggapan di sini
|
| 58 |
+
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
async def transcribe_audio(self, audio_file):
|
| 61 |
input_audio, _ = torchaudio.load(audio_file)
|