# Usar Faster Whisper en Windows

**0. Crear archivo para script en archivo de notas,** guardar como “[transcribe.py](http://transcribe.py)” seleccionando "todos los archivos" al momento de guardar en el tipo de archivo, no txt.

**1.1. Editar script si se requiere transcripción desde audio,** editar script “[transcribe.py](http://transcribe.py)” (tamaño del modelo (Ln 7) y/o ruta y nombre del audio (Ln 4))

{% code title="transcribe.py" lineNumbers="true" %}

```
from faster_whisper import WhisperModel

# Ruta del archivo de audio
audio_path = r"C:\Users\User\Music\Audio.ogg"

# Tamaño del modelo (puedes cambiar a "base", "medium", "large-v2", etc.)
model = WhisperModel("small")

# Transcribe el audio
segments, info = model.transcribe(audio_path)

# Muestra el idioma detectado y el texto
print("Idioma detectado:", info.language)

for segment in segments:
    print(f"[{segment.start:.2f}s -> {segment.end:.2f}s] {segment.text}")
```

{% endcode %}

**1.2. Editar script si se requiere transcripción desde video**, editar script “[transcribe.py](http://transcribe.py)” (tamaño del modelo (Ln 37) y/o ruta y nombre del video (Ln 8))

{% code title="transcribe.py" lineNumbers="true" %}

```
import os
import subprocess
from faster_whisper import WhisperModel
from pathlib import Path

# === Configuración ===
# Ruta del video
video_path = r"C:\Users\User\Videos\video.mp4"

# Carpeta temporal para el audio extraído
temp_audio_path = "temp_audio.wav"

# Carpeta Escritorio del usuario actual
desktop_folder = str(Path.home() / "Desktop")
output_text_file = os.path.join(desktop_folder, "transcripcion.txt")

# === Paso 1: Extraer audio del video usando ffmpeg ===
print(" Extrayendo audio del video...")
ffmpeg_command = [
    "ffmpeg", "-y",  # -y para sobrescribir sin preguntar
    "-i", video_path,
    "-vn",           # No video
    "-acodec", "pcm_s16le",  # Audio sin compresión (WAV)
    "-ar", "16000",  # Sample rate
    "-ac", "1",      # Mono
    temp_audio_path
]

try:
    subprocess.run(ffmpeg_command, check=True)
except subprocess.CalledProcessError:
    print(" Error al extraer el audio con ffmpeg.")
    exit(1)

# === Paso 2: Transcribir con Faster-Whisper  (puedes cambiar a "base", "medium", "large-v2", etc.) ===
print(" Transcribiendo audio...")
model = WhisperModel("large-v2")

segments, info = model.transcribe(temp_audio_path)

# === Paso 3: Guardar transcripción ===
print("Guardando transcripción...")
with open(output_text_file, "w", encoding="utf-8") as f:
    f.write(f"Idioma detectado: {info.language}\n\n")
    for segment in segments:
        f.write(f"[{segment.start:.2f}s -> {segment.end:.2f}s] {segment.text}\n")

print(f"Transcripción guardada en: {output_text_file}")

# === Paso 4: Eliminar archivo temporal ===
os.remove(temp_audio_path)
print(" Audio temporal eliminado.")
```

{% endcode %}

**2. Abrir terminal en la carpeta  del archivo**

I.  Abre el Explorador de archivos y navega a la carpeta donde guardaste transcribe.py.

II. Haz clic derecho sobre un espacio en blanco dentro de la carpeta (no sobre un archivo).

III. Selecciona: “Abrir en Terminal” (En versiones anteriores de Windows puede aparecer como “Abrir ventana de PowerShell aquí”).

**3. Ejecutar script**

```
python transcribe.py
```

**4. Obtención de resultado**

* Transcripción en terminal
* Archivo txt guardado en escritorio llamado transcripcion.txt<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dojo.lkmx.io/faster-whisper/usar-faster-whisper-en-windows.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
