Freddolin commited on
Commit
58d3fcd
·
verified ·
1 Parent(s): b32946b

Rename asr_tool.py to system_prompt.txt

Browse files
Files changed (2) hide show
  1. asr_tool.py +0 -35
  2. system_prompt.txt +18 -0
asr_tool.py DELETED
@@ -1,35 +0,0 @@
1
- from faster_whisper import WhisperModel
2
- import os
3
- import torch # Lägg till import av torch för att kontrollera GPU
4
-
5
- # Globalt model för att undvika återladdning
6
- model = None
7
-
8
- def get_model():
9
- global model
10
- if model is None:
11
- # Kontrollera om GPU är tillgänglig och använd den
12
- device = "cuda" if torch.cuda.is_available() else "cpu"
13
- # Använd float16 för att dra nytta av GPU:n, int8_float16 är också ett alternativ
14
- compute_type = "float16" if device == "cuda" else "int8"
15
- print(f"Laddar Whisper-modell på {device} med compute_type={compute_type}")
16
- model = WhisperModel("base", device=device, compute_type=compute_type)
17
- return model
18
-
19
- def transcribe_audio(audio_path: str) -> str:
20
- """Transkribera ljudfil till text"""
21
- try:
22
- if not os.path.exists(audio_path):
23
- return f"Audio file not found: {audio_path}"
24
-
25
- model = get_model()
26
- segments, info = model.transcribe(audio_path, beam_size=5)
27
-
28
- transcription = " ".join(segment.text for segment in segments)
29
- return transcription.strip() or "No transcription found."
30
-
31
- except Exception as e:
32
- return f"Error transcribing audio: {str(e)}"
33
-
34
-
35
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
system_prompt.txt ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ You are a helpful assistant tasked with answering questions using a set of tools.
2
+
3
+ Your final answer must strictly follow this format:
4
+ FINAL ANSWER: [ANSWER]
5
+
6
+ Only write the answer in that exact format. Do not explain anything. Do not include any other text.
7
+
8
+ If you are provided with a similar question and its final answer, and the current question is **exactly the same**, then simply return the same final answer without using any tools.
9
+
10
+ Only use tools if the current question is different from the similar one.
11
+
12
+ Examples:
13
+ - FINAL ANSWER: FunkMonk
14
+ - FINAL ANSWER: Paris
15
+ - FINAL ANSWER: 128
16
+
17
+ If you do not follow this format exactly, your response will be considered incorrect.
18
+