{"id":357942,"date":"2024-05-21T00:01:25","date_gmt":"2024-05-21T00:01:25","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=357942"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-21T00:01:25","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=357942","title":{"rendered":"<span>\u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0447\u0438 (\u0442\u0440\u0430\u043d\u0441\u043a\u0440\u0438\u0431\u0430\u0446\u0438\u044f) \u043f\u043e \u0430\u0443\u0434\u0438\u043e\u0437\u0430\u043f\u0438\u0441\u044f\u043c \u0434\u0438\u0430\u043b\u043e\u0433\u043e\u0432. Whisper. \u041b\u0438\u0447\u043d\u044b\u0439 \u043e\u043f\u044b\u0442<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/651\/e3f\/67e\/651e3f67e7992395eccc86107641e48d.png\" width=\"1024\" height=\"1024\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/651\/e3f\/67e\/651e3f67e7992395eccc86107641e48d.png\"\/><\/figure>\n<p>\u041f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430: <br \/>\u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u0440\u0435\u0447\u044c \u043f\u043e \u0430\u0443\u0434\u0438\u043e\u0437\u0430\u043f\u0438\u0441\u044f\u043c \u0434\u0438\u0430\u043b\u043e\u0433\u043e\u0432 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c Whisper.<br \/>\u0420\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0432 Colab.<\/p>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0447\u0438 \u0434\u0430\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c Whisper \u0438\u043c\u0435\u0435\u0442 \u0448\u0442\u0430\u0442\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0442\u0430\u0439\u043c\u0438\u043d\u0433\u0430.<br \/>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0440\u0435\u0441\u0443\u0440\u0441 \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f <a href=\"https:\/\/github.com\/openai\/whisper\/\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. <\/p>\n<p>\u041f\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438: <\/p>\n<blockquote>\n<p>Whisper \u2014 \u044d\u0442\u043e \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0447\u0438.\u00a0\u041e\u043d\u0430 \u043e\u0431\u0443\u0447\u0435\u043d\u0430 \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e\u0433\u043e \u0430\u0443\u0434\u0438\u043e, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043c\u043d\u043e\u0433\u043e\u0437\u0430\u0434\u0430\u0447\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043c\u043d\u043e\u0433\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0447\u0438, \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0440\u0435\u0447\u0438 \u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u044f\u0437\u044b\u043a\u0430.<\/p>\n<\/blockquote>\n<h2>\u0411\u0430\u0437\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/h2>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e. <\/p>\n<p>\u0415\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0439 (tiny, base, small, medium, large), \u0432 Colab \u043f\u043e\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u0432\u0441\u0435.<\/p>\n<pre><code>!pip install -U openai-whisper import whisper  model_name = 'large' model = whisper.load_model(model_name)<\/code><\/pre>\n<p>\u0411\u0430\u0437\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435.<\/p>\n<pre><code>result = model.transcribe(file) print(result[\"text\"])<\/code><\/pre>\n<p>\u041c\u044b \u0436\u0435 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u0440\u0435\u0447\u044c \u0434\u0432\u0443\u0445 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u0432 \u0434\u0432\u0443\u0445\u043a\u0430\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u0430\u0443\u0434\u0438\u043e\u0444\u0430\u0439\u043b\u0435 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0430\u0439\u043c\u0438\u043d\u0433.<\/p>\n<h2>\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0430\u0443\u0434\u0438\u043e\u0444\u0430\u0439\u043b<\/h2>\n<p>\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0441 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430, \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0430\u043f\u043a\u0443 \u0434\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0435\u0433\u043e \u0430\u0440\u0445\u0438\u0432\u0430.<\/p>\n<pre><code>import os from google.colab import files  uploaded = files.upload() file = next(iter(uploaded.keys())) source_file_name = file.replace('.wav','')  path = \"\/content\/\" + source_file_name os.mkdir(path)<\/code><\/pre>\n<p>\u0423\u0431\u0435\u0436\u0434\u0430\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u0432\u0435\u0440\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0438 \u0447\u0442\u043e \u0432 \u0444\u0430\u0439\u043b\u0435 2 \u043a\u0430\u043d\u0430\u043b\u0430.<\/p>\n<pre><code>print(source_file_name)  audio_file = wave.open(source_file_name + '.wav') CHANNELS = audio_file.getnchannels() print(\"\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u043d\u0430\u043b\u043e\u0432:\", CHANNELS)<\/code><\/pre>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u044f\u0437\u044b\u043a<\/p>\n<pre><code># load audio and pad\/trim it to fit 30 seconds audio = whisper.load_audio(source_file_name + '.wav') audio = whisper.pad_or_trim(audio)  # make log-Mel spectrogram and move to the same device as the model mel = whisper.log_mel_spectrogram(audio).to(model.device)  # detect the spoken language _, probs = model.detect_language(mel) print(f\"Detected language: {max(probs, key=probs.get)}\")<\/code><\/pre>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u044f\u0437\u044b\u043a\u0430 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u043f\u0435\u0440\u0432\u044b\u043c 30 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u043c. \u042d\u0442\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u0432\u0432\u043e\u0434\u0438\u0442 \u0432 \u0437\u0430\u0431\u043b\u0443\u0436\u0434\u0435\u043d\u0438\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043d\u0438\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u044f\u0437\u044b\u043a\u0435, \u0430 \u043f\u043e\u0442\u043e\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0447\u0442\u043e \u0438\u043c \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0440\u0430\u0437\u0433\u043e\u0432\u0430\u0440\u0438\u0432\u0430\u0442\u044c \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u043c \u044f\u0437\u044b\u043a\u0435 \u0438 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u044f\u0437\u044b\u043a.<\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u0435\u043c 2 \u0444\u0430\u0439\u043b\u0430 \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u0434\u043e\u0440\u043e\u0436\u043a\u0435<\/h2>\n<p>\u042d\u0442\u0430 \u0447\u0430\u0441\u0442\u044c \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a Whisper \u0438 \u043a \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044e \u0440\u0435\u0447\u0438. \u0417\u0434\u0435\u0441\u044c \u0447\u0438\u0442\u0430\u0435\u043c \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u0432\u0441\u0435 \u0441\u0435\u043c\u043f\u043b\u044b, \u043e\u0431\u043d\u0443\u043b\u044f\u0435\u043c \u043a\u0430\u0436\u0434\u044b\u0439 \u0447\u0435\u0442\u043d\u044b\u0439 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u0441 \u043d\u0435\u0447\u0435\u0442\u043d\u044b\u043c\u0438 \u0441\u0435\u043c\u043f\u043b\u0430\u043c\u0438. <\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0440\u0430\u0437\u0431\u0438\u0432\u043a\u0438 \u0444\u0430\u0439\u043b\u0430 \u043d\u0430 2 \u0434\u043e\u0440\u043e\u0436\u043a\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>import wave, struct  # \u0444\u0430\u0439\u043b \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043d\u0430 \u0434\u0432\u0435 \u0434\u043e\u0440\u043e\u0436\u043a\u0438 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430  audio_file = wave.open(source_file_name + '.wav')  SAMPLE_WIDTH = audio_file.getsampwidth() # \u0433\u043b\u0443\u0431\u0438\u043d\u0430 \u0437\u0432\u0443\u043a\u0430 CHANNELS = audio_file.getnchannels() # \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u043d\u0430\u043b\u043e\u0432 FRAMERATE = audio_file.getframerate() # \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u0438\u0437\u0430\u0446\u0438\u0438 N_SAMPLES = audio_file.getnframes() # \u043a\u043e\u043b-\u0432\u043e \u0441\u0435\u043c\u043f\u043b\u043e\u0432 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u0430\u043d\u0430\u043b  N_FRAMES = audio_file.getnframes()  # \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0430\u0443\u0434\u0438\u043e\u0444\u0430\u0439\u043b\u0430  nchannels = CHANNELS sampwidth = SAMPLE_WIDTH framerate = FRAMERATE nframes = N_FRAMES  comptype = \"NONE\"  # \u0442\u0438\u043f \u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438 compname = \"not compressed\"  # \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438  # \u0443\u0437\u043d\u0430\u0435\u043c \u043a\u043e\u043b-\u0432\u043e \u0441\u0435\u043c\u043f\u043b\u043e\u0432 \u0438 \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u0432 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0435 N_SAMPLES = nframes CHANNELS = nchannels  def create_file_one_channel(name):    # \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0443\u0441\u0442\u043e\u0439 \u0444\u0430\u0439\u043b \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 wb (write binary)   out_file = wave.open(name, \"wb\")    # \u0432 \"\u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438\" \u0444\u0430\u0439\u043b\u0430 \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0442\u0435 \u0436\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0447\u0442\u043e \u0438 \u0443 \"\u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\"   out_file.setframerate(framerate)   out_file.setsampwidth(sampwidth)   out_file.setnchannels(CHANNELS)    # \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043f\u0435\u0440\u0435\u0433\u043e\u043d\u044f\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0447\u0438\u0441\u0435\u043b \u0432 \u0431\u0430\u0439\u0442-\u0441\u0442\u0440\u043e\u043a\u0443   audio_data = struct.pack(f\"&lt;{N_SAMPLES * CHANNELS}h\", *values_copy)    # \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0444\u0430\u0439\u043b \u0441 \u0440\u0435\u0437\u0445\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c   out_file.writeframes(audio_data)  ##########  print('started')  # \u0447\u0438\u0442\u0430\u0435\u043c \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u0432\u0441\u0435 \u0441\u0435\u043c\u043f\u043b\u044b samples = audio_file.readframes(N_FRAMES)  # \u043f\u0440\u043e\u0441\u0438\u043c struct \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u0438\u0437 \u0431\u0430\u0439\u0442 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0447\u0438\u0441\u0435\u043b # &lt; - \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0431\u0438\u0442\u043e\u0432 \u0432 \u0431\u0430\u0439\u0442\u0435 (\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043a\u0430 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a) # \u041f\u043e \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0447\u0438\u0441\u0435\u043b, \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043a\u043e\u043b-\u0432\u0430 \u0441\u0435\u043c\u043f\u043b\u043e\u0432 \u0432 \u043e\u0434\u043d\u043e\u043c \u043a\u0430\u043d\u0430\u043b\u0435 \u043d\u0430 \u043a\u043e\u043b-\u0432\u043e \u043a\u0430\u043d\u0430\u043b\u043e\u043e\u0432 # h - \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0432\u0430 \u0431\u0430\u0439\u0442\u0430  values = list(struct.unpack(\"&lt;\" + str(N_FRAMES * CHANNELS) + \"h\", samples)) print(values[:20])  values_copy = values[:]  # \u043e\u0431\u043d\u0443\u043b\u0438\u043c \u043a\u0430\u0436\u0434\u043e\u0435 \u0447\u0435\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 for index, i in enumerate(values_copy):     if index % 2 == 0:       values_copy[index] = 0  create_file_one_channel('1_channel.wav') print(values_copy[:20])  values_copy = values[:]  # \u043e\u0431\u043d\u0443\u043b\u0438\u043c \u043a\u0430\u0436\u0434\u043e\u0435 \u043d\u0435\u0447\u0435\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 for index, i in enumerate(values_copy):     if index % 2 != 0:       values_copy[index] = 0  create_file_one_channel('2_channel.wav') print(values_copy[:20])<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0444\u0430\u0439\u043b 1-\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430 \u0438 \u0444\u0430\u0439\u043b 2-\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430: 1_channel.wav \u0438 2_channel.wav.<\/p>\n<h2>\u0422\u0440\u0430\u043d\u0441\u043a\u0440\u0438\u0431\u0430\u0446\u0438\u044f 1 \u043a\u0430\u043d\u0430\u043b\u0430<\/h2>\n<p>\u0422\u0440\u0430\u043d\u0441\u043a\u0440\u0438\u0431\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b \u0441 1 \u043a\u0430\u043d\u0430\u043b\u043e\u043c<\/p>\n<pre><code>from datetime import timedelta  source_file_name_channel = '1_channel' print(source_file_name_channel)  # load audio and pad\/trim it to fit 30 seconds audio = whisper.load_audio(source_file_name_channel + '.wav') audio = whisper.pad_or_trim(audio)  # make log-Mel spectrogram and move to the same device as the model mel = whisper.log_mel_spectrogram(audio).to(model.device)  # detect the spoken language _, probs = model.detect_language(mel) print(f\"Detected language: {max(probs, key=probs.get)}\") print('started...') print()  result = model.transcribe(source_file_name_channel + '.wav',)  segments = result['segments']  text_massive = []  for segment in segments:     startTime = str(0)+str(timedelta(seconds=int(segment['start'])))     endTime = str(0)+str(timedelta(seconds=int(segment['end'])))     text = segment['text']     segmentId = segment['id']+1     segment = f\"{segmentId}. {startTime} - {endTime}\\n{text[1:] if text[0] == ' ' else text}\"     #print(segment)     text_massive.append(segment)  print() print('Finished')<\/code><\/pre>\n<p>\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u0444\u0430\u0439\u043b \u0444\u043e\u0440\u043c\u0430\u0442\u0430 docx.<\/p>\n<pre><code>!pip install python-docx from docx import Document  # \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0442\u0435\u043a\u0441\u0442 \u0441 \u0442\u0430\u0439\u043c\u0438\u043d\u0433\u043e\u043c  text = text_massive  # \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 doc = Document()  # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444 \u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u043c doc.add_paragraph(source_file_name + '_' + source_file_name_channel + '_' + model_name) for key in text:   doc.add_paragraph(key)  # \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 doc.save(path + '\/' + source_file_name + '_' + source_file_name_channel + '_text_timing_' + model_name + '.docx')<\/code><\/pre>\n<p>\u0421\u043e \u0432\u0442\u043e\u0440\u044b\u043c \u043a\u0430\u043d\u0430\u043b\u043e\u043c \u0432\u0441\u0435 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043c\u0435\u0441\u0442\u043e &#171;1_channel&#187; \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c &#171;2_channel&#187;.<br \/>\u0422\u0430\u043a\u0436\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0446\u0438\u043a\u043b \u0438\u0437 \u044d\u0442\u0438\u0445 \u0434\u0432\u0443\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043d\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u043e. <\/p>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 2 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0444\u0430\u0439\u043b\u0430 \u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u0438 \u0442\u0430\u0439\u043c\u0438\u043d\u0433\u043e\u043c, \u0438 \u044d\u0442\u0438 \u0444\u0430\u0439\u043b\u0430 \u043b\u0435\u0436\u0430\u0442 \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0439 \u0440\u0430\u043d\u0435\u0435 \u043f\u0430\u043f\u043a\u0435 \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c. \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0430\u0440\u0445\u0438\u0432 \u0438 \u0441\u043a\u0430\u0447\u0430\u0442\u044c.<\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u0430\u0440\u0445\u0438\u0432\u0430<\/h2>\n<pre><code>import shutil\/  # \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0430\u0440\u0445\u0438\u0432\u0430 \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0438\u0437 \u043f\u0430\u043f\u043a\u0438 shutil.make_archive(path + '_' + model_name, 'zip', path)  # \u0421\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u0430\u0440\u0445\u0438\u0432\u0430 files.download(path + '_' + model_name + '.zip')<\/code><\/pre>\n<h2>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043f\u0430\u043f\u043e\u043a<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c &#171;\u0432\u0440\u0443\u0447\u043d\u0443\u044e&#187; \u0435\u0449\u0435 \u0444\u0430\u0439\u043b, \u0442\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0443\u0434\u0430\u043b\u0438\u0442 \u0438\u0437 Colab \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0440\u0430\u043d\u0435\u0435 \u0444\u0430\u0439\u043b\u044b \u0438 \u043f\u0430\u043f\u043a\u0438.<\/p>\n<pre><code># \u0437\u0430\u0434\u0430\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u0432\u0441\u0435 \u0438 \u0441\u0440\u0430\u0437\u0443 \u0432\u0441\u0435 \u0443\u0434\u0430\u043b\u044f\u0435\u043c  file_massive = [     source_file_name + '.wav',     source_file_name + '_' + model_name + '.zip',     '1_channel.wav',     '2_channel.wav',     path + '\/' + source_file_name + '_1_channel_text_timing_' + model_name + '.docx',     path + '\/' + source_file_name + '_2_channel_text_timing_' + model_name + '.docx'   ]  # \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 for key in file_massive:   print(key)   os.remove(key) print()  # \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043f\u043a\u0438 print(path) os.rmdir(path) print()  print('Finished')<\/code><\/pre>\n<p>Colab \u043e\u0447\u0438\u0449\u0435\u043d \u0438 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0434\u0440\u0443\u0433\u0438\u043c \u0444\u0430\u0439\u043b\u043e\u043c.<\/p>\n<h2>\u0414\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043a\u0430\u0447\u0430\u0442\u044c \u0432\u0441\u0435 \u0430\u0443\u0434\u0438\u043e\u0444\u0430\u0439\u043b\u044b \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432\u0441\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u043f\u043e\u0434\u0440\u044f\u0434 \u0432 \u0435\u0434\u0438\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435.<\/p>\n<p>\u0421\u043e\u0432\u0441\u0435\u043c \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0438\u0437 \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438\u043b\u0438 \u0438\u0437 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0438 \u043f\u043e\u0441\u043b\u0435 \u0442\u0440\u0430\u043d\u0441\u043a\u0440\u0438\u0431\u0430\u0446\u0438\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0434\u0438\u0430\u043b\u043e\u0433 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438\u043b\u0438 \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435.<\/p>\n<h2>\u0422\u0440\u0430\u043d\u0441\u043a\u0440\u0438\u0431\u0430\u0446\u0438\u044f \u0441\u0440\u0430\u0437\u0443 \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0439<\/h2>\n<p>\u0412 Whisper \u0435\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c &#8212; \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0439, \u043c\u0438\u043d\u0443\u044f \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0432\u044b\u0432\u043e\u0434. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u0435\u0441\u043b\u0438 \u0444\u0430\u0439\u043b\u044b \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u0438 \u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0434\u0438\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0446\u0435\u043b\u0435\u0441\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u0432\u0441\u0435 \u0434\u0438\u0430\u043b\u043e\u0433\u0438 \u043a \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u043c\u0443 \u0438 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0443\u0436\u0435 \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u043c.<\/p>\n<p>\u0414\u043b\u044f \u0442\u0440\u0430\u043d\u0441\u043a\u0440\u0438\u0431\u0430\u0446\u0438\u0438 \u0441\u0440\u0430\u0437\u0443 \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435.<\/p>\n<pre><code>result = model.transcribe(source_file_name_channel + '.wav', task=\"translate\")<\/code><\/pre>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u0412\u044b \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b\u0438 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0435\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c, \u0438\u043b\u0438 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0447\u0442\u043e-\u043b\u0438\u0431\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c &#8212; \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.  <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/98e\/6fa\/1a5\/98e6fa1a5e8154ce7e5241e7b821f9f4.png\" width=\"1024\" height=\"1024\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/98e\/6fa\/1a5\/98e6fa1a5e8154ce7e5241e7b821f9f4.png\"\/><\/figure>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/768562\/\"> https:\/\/habr.com\/ru\/articles\/768562\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430: <br \/>\u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u0440\u0435\u0447\u044c \u043f\u043e \u0430\u0443\u0434\u0438\u043e\u0437\u0430\u043f\u0438\u0441\u044f\u043c \u0434\u0438\u0430\u043b\u043e\u0433\u043e\u0432 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c Whisper.<br \/>\u0420\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0432 Colab.<\/p>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0447\u0438 \u0434\u0430\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c Whisper \u0438\u043c\u0435\u0435\u0442 \u0448\u0442\u0430\u0442\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0442\u0430\u0439\u043c\u0438\u043d\u0433\u0430.<br \/>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0440\u0435\u0441\u0443\u0440\u0441 \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f <a href=\"https:\/\/github.com\/openai\/whisper\/\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. <\/p>\n<p>\u041f\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438: <\/p>\n<blockquote>\n<p>Whisper \u2014 \u044d\u0442\u043e \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0447\u0438.\u00a0\u041e\u043d\u0430 \u043e\u0431\u0443\u0447\u0435\u043d\u0430 \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e\u0433\u043e \u0430\u0443\u0434\u0438\u043e, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043c\u043d\u043e\u0433\u043e\u0437\u0430\u0434\u0430\u0447\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043c\u043d\u043e\u0433\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0447\u0438, \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0440\u0435\u0447\u0438 \u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u044f\u0437\u044b\u043a\u0430.<\/p>\n<\/blockquote>\n<h2>\u0411\u0430\u0437\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/h2>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e. <\/p>\n<p>\u0415\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0439 (tiny, base, small, medium, large), \u0432 Colab \u043f\u043e\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u0432\u0441\u0435.<\/p>\n<pre><code>!pip install -U openai-whisper import whisper  model_name = 'large' model = whisper.load_model(model_name)<\/code><\/pre>\n<p>\u0411\u0430\u0437\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435.<\/p>\n<pre><code>result = model.transcribe(file) print(result[\"text\"])<\/code><\/pre>\n<p>\u041c\u044b \u0436\u0435 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u0440\u0435\u0447\u044c \u0434\u0432\u0443\u0445 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u0432 \u0434\u0432\u0443\u0445\u043a\u0430\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u0430\u0443\u0434\u0438\u043e\u0444\u0430\u0439\u043b\u0435 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0430\u0439\u043c\u0438\u043d\u0433.<\/p>\n<h2>\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0430\u0443\u0434\u0438\u043e\u0444\u0430\u0439\u043b<\/h2>\n<p>\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0441 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430, \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0430\u043f\u043a\u0443 \u0434\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0435\u0433\u043e \u0430\u0440\u0445\u0438\u0432\u0430.<\/p>\n<pre><code>import os from google.colab import files  uploaded = files.upload() file = next(iter(uploaded.keys())) source_file_name = file.replace('.wav','')  path = \"\/content\/\" + source_file_name os.mkdir(path)<\/code><\/pre>\n<p>\u0423\u0431\u0435\u0436\u0434\u0430\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u0432\u0435\u0440\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0438 \u0447\u0442\u043e \u0432 \u0444\u0430\u0439\u043b\u0435 2 \u043a\u0430\u043d\u0430\u043b\u0430.<\/p>\n<pre><code>print(source_file_name)  audio_file = wave.open(source_file_name + '.wav') CHANNELS = audio_file.getnchannels() print(\"\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u043d\u0430\u043b\u043e\u0432:\", CHANNELS)<\/code><\/pre>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u044f\u0437\u044b\u043a<\/p>\n<pre><code># load audio and pad\/trim it to fit 30 seconds audio = whisper.load_audio(source_file_name + '.wav') audio = whisper.pad_or_trim(audio)  # make log-Mel spectrogram and move to the same device as the model mel = whisper.log_mel_spectrogram(audio).to(model.device)  # detect the spoken language _, probs = model.detect_language(mel) print(f\"Detected language: {max(probs, key=probs.get)}\")<\/code><\/pre>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u044f\u0437\u044b\u043a\u0430 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u043f\u0435\u0440\u0432\u044b\u043c 30 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u043c. \u042d\u0442\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u0432\u0432\u043e\u0434\u0438\u0442 \u0432 \u0437\u0430\u0431\u043b\u0443\u0436\u0434\u0435\u043d\u0438\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043d\u0438\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u044f\u0437\u044b\u043a\u0435, \u0430 \u043f\u043e\u0442\u043e\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0447\u0442\u043e \u0438\u043c \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0440\u0430\u0437\u0433\u043e\u0432\u0430\u0440\u0438\u0432\u0430\u0442\u044c \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u043c \u044f\u0437\u044b\u043a\u0435 \u0438 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u044f\u0437\u044b\u043a.<\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u0435\u043c 2 \u0444\u0430\u0439\u043b\u0430 \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u0434\u043e\u0440\u043e\u0436\u043a\u0435<\/h2>\n<p>\u042d\u0442\u0430 \u0447\u0430\u0441\u0442\u044c \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a Whisper \u0438 \u043a \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044e \u0440\u0435\u0447\u0438. \u0417\u0434\u0435\u0441\u044c \u0447\u0438\u0442\u0430\u0435\u043c \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u0432\u0441\u0435 \u0441\u0435\u043c\u043f\u043b\u044b, \u043e\u0431\u043d\u0443\u043b\u044f\u0435\u043c \u043a\u0430\u0436\u0434\u044b\u0439 \u0447\u0435\u0442\u043d\u044b\u0439 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u0441 \u043d\u0435\u0447\u0435\u0442\u043d\u044b\u043c\u0438 \u0441\u0435\u043c\u043f\u043b\u0430\u043c\u0438. <\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0440\u0430\u0437\u0431\u0438\u0432\u043a\u0438 \u0444\u0430\u0439\u043b\u0430 \u043d\u0430 2 \u0434\u043e\u0440\u043e\u0436\u043a\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>import wave, struct  # \u0444\u0430\u0439\u043b \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043d\u0430 \u0434\u0432\u0435 \u0434\u043e\u0440\u043e\u0436\u043a\u0438 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430  audio_file = wave.open(source_file_name + '.wav')  SAMPLE_WIDTH = audio_file.getsampwidth() # \u0433\u043b\u0443\u0431\u0438\u043d\u0430 \u0437\u0432\u0443\u043a\u0430 CHANNELS = audio_file.getnchannels() # \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0430\u043d\u0430\u043b\u043e\u0432 FRAMERATE = audio_file.getframerate() # \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u0438\u0437\u0430\u0446\u0438\u0438 N_SAMPLES = audio_file.getnframes() # \u043a\u043e\u043b-\u0432\u043e \u0441\u0435\u043c\u043f\u043b\u043e\u0432 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u0430\u043d\u0430\u043b  N_FRAMES = audio_file.getnframes()  # \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0430\u0443\u0434\u0438\u043e\u0444\u0430\u0439\u043b\u0430  nchannels = CHANNELS sampwidth = SAMPLE_WIDTH framerate = FRAMERATE nframes = N_FRAMES  comptype = \"NONE\"  # \u0442\u0438\u043f \u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438 compname = \"not compressed\"  # \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438  # \u0443\u0437\u043d\u0430\u0435\u043c \u043a\u043e\u043b-\u0432\u043e \u0441\u0435\u043c\u043f\u043b\u043e\u0432 \u0438 \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u0432 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0435 N_SAMPLES = nframes CHANNELS = nchannels  def create_file_one_channel(name):    # \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0443\u0441\u0442\u043e\u0439 \u0444\u0430\u0439\u043b \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 wb (write binary)   out_file = wave.open(name, \"wb\")    # \u0432 \"\u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438\" \u0444\u0430\u0439\u043b\u0430 \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0442\u0435 \u0436\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0447\u0442\u043e \u0438 \u0443 \"\u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\"   out_file.setframerate(framerate)   out_file.setsampwidth(sampwidth)   out_file.setnchannels(CHANNELS)    # \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043f\u0435\u0440\u0435\u0433\u043e\u043d\u044f\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0447\u0438\u0441\u0435\u043b \u0432 \u0431\u0430\u0439\u0442-\u0441\u0442\u0440\u043e\u043a\u0443   audio_data = struct.pack(f\"&lt;{N_SAMPLES * CHANNELS}h\", *values_copy)    # \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0444\u0430\u0439\u043b \u0441 \u0440\u0435\u0437\u0445\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c   out_file.writeframes(audio_data)  ##########  print('started')  # \u0447\u0438\u0442\u0430\u0435\u043c \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u0432\u0441\u0435 \u0441\u0435\u043c\u043f\u043b\u044b samples = audio_file.readframes(N_FRAMES)  # \u043f\u0440\u043e\u0441\u0438\u043c struct \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u0438\u0437 \u0431\u0430\u0439\u0442 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0447\u0438\u0441\u0435\u043b # &lt; - \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0431\u0438\u0442\u043e\u0432 \u0432 \u0431\u0430\u0439\u0442\u0435 (\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043a\u0430 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a) # \u041f\u043e \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0447\u0438\u0441\u0435\u043b, \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043a\u043e\u043b-\u0432\u0430 \u0441\u0435\u043c\u043f\u043b\u043e\u0432 \u0432 \u043e\u0434\u043d\u043e\u043c \u043a\u0430\u043d\u0430\u043b\u0435 \u043d\u0430 \u043a\u043e\u043b-\u0432\u043e \u043a\u0430\u043d\u0430\u043b\u043e\u043e\u0432 # h - \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0432\u0430 \u0431\u0430\u0439\u0442\u0430  values = list(struct.unpack(\"&lt;\" + str(N_FRAMES * CHANNELS) + \"h\", samples)) print(values[:20])  values_copy = values[:]  # \u043e\u0431\u043d\u0443\u043b\u0438\u043c \u043a\u0430\u0436\u0434\u043e\u0435 \u0447\u0435\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 for index, i in enumerate(values_copy):     if index % 2 == 0:       values_copy[index] = 0  create_file_one_channel('1_channel.wav') print(values_copy[:20])  values_copy = values[:]  # \u043e\u0431\u043d\u0443\u043b\u0438\u043c \u043a\u0430\u0436\u0434\u043e\u0435 \u043d\u0435\u0447\u0435\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 for index, i in enumerate(values_copy):     if index % 2 != 0:       values_copy[index] = 0  create_file_one_channel('2_channel.wav') print(values_copy[:20])<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0444\u0430\u0439\u043b 1-\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430 \u0438 \u0444\u0430\u0439\u043b 2-\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430: 1_channel.wav \u0438 2_channel.wav.<\/p>\n<h2>\u0422\u0440\u0430\u043d\u0441\u043a\u0440\u0438\u0431\u0430\u0446\u0438\u044f 1 \u043a\u0430\u043d\u0430\u043b\u0430<\/h2>\n<p>\u0422\u0440\u0430\u043d\u0441\u043a\u0440\u0438\u0431\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b \u0441 1 \u043a\u0430\u043d\u0430\u043b\u043e\u043c<\/p>\n<pre><code>from datetime import timedelta  source_file_name_channel = '1_channel' print(source_file_name_channel)  # load audio and pad\/trim it to fit 30 seconds audio = whisper.load_audio(source_file_name_channel + '.wav') audio = whisper.pad_or_trim(audio)  # make log-Mel spectrogram and move to the same device as the model mel = whisper.log_mel_spectrogram(audio).to(model.device)  # detect the spoken language _, probs = model.detect_language(mel) print(f\"Detected language: {max(probs, key=probs.get)}\") print('started...') print()  result = model.transcribe(source_file_name_channel + '.wav',)  segments = result['segments']  text_massive = []  for segment in segments:     startTime = str(0)+str(timedelta(seconds=int(segment['start'])))     endTime = str(0)+str(timedelta(seconds=int(segment['end'])))     text = segment['text']     segmentId = segment['id']+1     segment = f\"{segmentId}. {startTime} - {endTime}\\n{text[1:] if text[0] == ' ' else text}\"     #print(segment)     text_massive.append(segment)  print() print('Finished')<\/code><\/pre>\n<p>\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u0444\u0430\u0439\u043b \u0444\u043e\u0440\u043c\u0430\u0442\u0430 docx.<\/p>\n<pre><code>!pip install python-docx from docx import Document  # \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0442\u0435\u043a\u0441\u0442 \u0441 \u0442\u0430\u0439\u043c\u0438\u043d\u0433\u043e\u043c  text = text_massive  # \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 doc = Document()  # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444 \u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u043c doc.add_paragraph(source_file_name + '_' + source_file_name_channel + '_' + model_name) for key in text:   doc.add_paragraph(key)  # \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 doc.save(path + '\/' + source_file_name + '_' + source_file_name_channel + '_text_timing_' + model_name + '.docx')<\/code><\/pre>\n<p>\u0421\u043e \u0432\u0442\u043e\u0440\u044b\u043c \u043a\u0430\u043d\u0430\u043b\u043e\u043c \u0432\u0441\u0435 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043c\u0435\u0441\u0442\u043e &#171;1_channel&#187; \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c &#171;2_channel&#187;.<br \/>\u0422\u0430\u043a\u0436\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0446\u0438\u043a\u043b \u0438\u0437 \u044d\u0442\u0438\u0445 \u0434\u0432\u0443\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043d\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u044c\u043d\u043e. <\/p>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 2 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0444\u0430\u0439\u043b\u0430 \u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u0438 \u0442\u0430\u0439\u043c\u0438\u043d\u0433\u043e\u043c, \u0438 \u044d\u0442\u0438 \u0444\u0430\u0439\u043b\u0430 \u043b\u0435\u0436\u0430\u0442 \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0439 \u0440\u0430\u043d\u0435\u0435 \u043f\u0430\u043f\u043a\u0435 \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c. \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0430\u0440\u0445\u0438\u0432 \u0438 \u0441\u043a\u0430\u0447\u0430\u0442\u044c.<\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u0430\u0440\u0445\u0438\u0432\u0430<\/h2>\n<pre><code>import shutil\/  # \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0430\u0440\u0445\u0438\u0432\u0430 \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0438\u0437 \u043f\u0430\u043f\u043a\u0438 shutil.make_archive(path + '_' + model_name, 'zip', path)  # \u0421\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u0430\u0440\u0445\u0438\u0432\u0430 files.download(path + '_' + model_name + '.zip')<\/code><\/pre>\n<h2>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043f\u0430\u043f\u043e\u043a<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c &#171;\u0432\u0440\u0443\u0447\u043d\u0443\u044e&#187; \u0435\u0449\u0435 \u0444\u0430\u0439\u043b, \u0442\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0443\u0434\u0430\u043b\u0438\u0442 \u0438\u0437 Colab \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0440\u0430\u043d\u0435\u0435 \u0444\u0430\u0439\u043b\u044b \u0438 \u043f\u0430\u043f\u043a\u0438.<\/p>\n<pre><code># \u0437\u0430\u0434\u0430\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u0432\u0441\u0435 \u0438 \u0441\u0440\u0430\u0437\u0443 \u0432\u0441\u0435 \u0443\u0434\u0430\u043b\u044f\u0435\u043c  file_massive = [     source_file_name + '.wav',     source_file_name + '_' + model_name + '.zip',     '1_channel.wav',     '2_channel.wav',     path + '\/' + source_file_name + '_1_channel_text_timing_' + model_name + '.docx',     path + '\/' + source_file_name + '_2_channel_text_timing_' + model_name + '.docx'   ]  # \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 for key in file_massive:   print(key)   os.remove(key) print()  # \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043f\u043a\u0438 print(path) os.rmdir(path) print()  print('Finished')<\/code><\/pre>\n<p>Colab \u043e\u0447\u0438\u0449\u0435\u043d \u0438 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0434\u0440\u0443\u0433\u0438\u043c \u0444\u0430\u0439\u043b\u043e\u043c.<\/p>\n<h2>\u0414\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043a\u0430\u0447\u0430\u0442\u044c \u0432\u0441\u0435 \u0430\u0443\u0434\u0438\u043e\u0444\u0430\u0439\u043b\u044b \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432\u0441\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u043f\u043e\u0434\u0440\u044f\u0434 \u0432 \u0435\u0434\u0438\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435.<\/p>\n<p>\u0421\u043e\u0432\u0441\u0435\u043c \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0438\u0437 \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438\u043b\u0438 \u0438\u0437 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0438 \u043f\u043e\u0441\u043b\u0435 \u0442\u0440\u0430\u043d\u0441\u043a\u0440\u0438\u0431\u0430\u0446\u0438\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0434\u0438\u0430\u043b\u043e\u0433 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438\u043b\u0438 \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435.<\/p>\n<h2>\u0422\u0440\u0430\u043d\u0441\u043a\u0440\u0438\u0431\u0430\u0446\u0438\u044f \u0441\u0440\u0430\u0437\u0443 \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0439<\/h2>\n<p>\u0412 Whisper \u0435\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c &#8212; \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0439, \u043c\u0438\u043d\u0443\u044f \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0432\u044b\u0432\u043e\u0434. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u0435\u0441\u043b\u0438 \u0444\u0430\u0439\u043b\u044b \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u0438 \u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0434\u0438\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0446\u0435\u043b\u0435\u0441\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u0432\u0441\u0435 \u0434\u0438\u0430\u043b\u043e\u0433\u0438 \u043a \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u043c\u0443 \u0438 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0443\u0436\u0435 \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u043c.<\/p>\n<p>\u0414\u043b\u044f \u0442\u0440\u0430\u043d\u0441\u043a\u0440\u0438\u0431\u0430\u0446\u0438\u0438 \u0441\u0440\u0430\u0437\u0443 \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435.<\/p>\n<pre><code>result = model.transcribe(source_file_name_channel + '.wav', task=\"translate\")<\/code><\/pre>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u0412\u044b \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b\u0438 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0435\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c, \u0438\u043b\u0438 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0447\u0442\u043e-\u043b\u0438\u0431\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c &#8212; \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.  <\/p>\n<figure class=\"full-width\"><\/figure>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/768562\/\"> https:\/\/habr.com\/ru\/articles\/768562\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-357942","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/357942","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=357942"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/357942\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=357942"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=357942"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=357942"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}