Spaces:
Sleeping
Sleeping
Rename asr_tool.py to system_prompt.txt
Browse filesFiles changed (2)
- asr_tool.pyDeleted-35
- system_prompt.txtAdded+18
1234567891011121314151617181920212223242526272829303132333435from faster_whisper import WhisperModelimport osimport torch # Lägg till import av torch för att kontrollera GPU
# Globalt model för att undvika återladdningmodel = None
def get_model(): global model if model is None: # Kontrollera om GPU är tillgänglig och använd den device = "cuda" if torch.cuda.is_available() else "cpu" # Använd float16 för att dra nytta av GPU:n, int8_float16 är också ett alternativ compute_type = "float16" if device == "cuda" else "int8" print(f"Laddar Whisper-modell på {device} med compute_type={compute_type}") model = WhisperModel("base", device=device, compute_type=compute_type) return model
def transcribe_audio(audio_path: str) -> str: """Transkribera ljudfil till text""" try: if not os.path.exists(audio_path): return f"Audio file not found: {audio_path}" model = get_model() segments, info = model.transcribe(audio_path, beam_size=5) transcription = " ".join(segment.text for segment in segments) return transcription.strip() or "No transcription found." except Exception as e: return f"Error transcribing audio: {str(e)}"
123456789101112131415161718You are a helpful assistant tasked with answering questions using a set of tools.
Your final answer must strictly follow this format:FINAL ANSWER: [ANSWER]
Only write the answer in that exact format. Do not explain anything. Do not include any other text.
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.
Only use tools if the current question is different from the similar one.
Examples:- FINAL ANSWER: FunkMonk- FINAL ANSWER: Paris- FINAL ANSWER: 128
If you do not follow this format exactly, your response will be considered incorrect.
asr_tool.pyDeleted-35
system_prompt.txtAdded+18