Advertisement
load-net

whisper

Feb 26th, 2024 (edited)
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. ######## https://github.com/openai/whisper
  2.  
  3. apt install pip
  4. apt install python3.11-venv
  5. mkdir project
  6. cd /usr/src/project/
  7. python3 -m venv project/
  8. source /usr/src/project/bin/activate
  9. pip install -U openai-whisper
  10. alternative
  11. pip install git+https://github.com/openai/whisper.git
  12.  
  13. ####################################################
  14. touch my_whisper.py
  15.  
  16. import whisper
  17. import time
  18.  
  19. # Засекаем время начала выполнения кода
  20. start_time = time.time()
  21.  
  22.  
  23. ###########################################################################################
  24. #Size Parameters # English-only model # Multilingual model # Required # VRAM Relative speed
  25. #tiny 39 M # tiny.en # tiny # ~1 GB # ~32x
  26. #base 74 M # base.en # base # ~1 GB # ~16x
  27. #small 244 M # small.en # small # ~2 GB # ~6x
  28. #medium 769 M # medium.en # medium # ~5 GB # ~2x
  29. #large 1550 M # N/A # large # ~10 GB # 1x
  30.  
  31. ##########################################################################################
  32.  
  33.  
  34. #model = whisper.load_model("tiny")
  35. #model = whisper.load_model("base")
  36. model = whisper.load_model("small")
  37. #model = whisper.load_model("medium")
  38. #model = whisper.load_model("large")
  39.  
  40.  
  41.  
  42. result = model.transcribe("audio.wav")
  43.  
  44. # Открываем файл для записи
  45. with open("/home/load/output.txt", "w") as file:
  46. file.write(result["text"])
  47.  
  48. # Засекаем время окончания выполнения кода
  49. end_time = time.time()
  50.  
  51. # Вычисляем время выполнения в секундах
  52. execution_time = end_time - start_time
  53.  
  54. print(f"Результат успешно записан в файл output.txt")
  55. print(f"Время выполнения: {execution_time} секунд")
  56. ###################################################
  57. cd /usr/src/project
  58. python my_whisper.py
  59. ##################################################
  60.  
  61. sudo apt update && sudo apt install ffmpeg
  62.  
  63. deactivate
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement