{ "cells": [ { "cell_type": "code", "execution_count": 11, "id": "808d647c-deef-41ec-8a69-06f7a72689cb", "metadata": {}, "outputs": [], "source": [ "import torch" ] }, { "cell_type": "code", "execution_count": null, "id": "e49e45a1-2133-487c-a8bc-69caed303074", "metadata": {}, "outputs": [], "source": [ "#!pip install pyannote.audio==1.1.1\n", "#!pip install pyannote.core[notebook]\n", "#!pip install pyannote.pipeline\n", "#!pip install pyannote.core\n", "!pip install ipywidgets" ] }, { "cell_type": "code", "execution_count": 12, "id": "59437acd-b487-4531-bb4e-a4c216a67a29", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Using cache found in /home/reves/.cache/torch/hub/pyannote_pyannote-audio_master\n", "Using cache found in /home/reves/.cache/torch/hub/pyannote_pyannote-audio_master\n", "Using cache found in /home/reves/.cache/torch/hub/pyannote_pyannote-audio_master\n", "Using cache found in /home/reves/.cache/torch/hub/pyannote_pyannote-audio_master\n", "/home/reves/plume-asr/.direnv/python-3.8.10/lib/python3.8/site-packages/pyannote/audio/embedding/approaches/arcface_loss.py:170: FutureWarning: The 's' parameter is deprecated in favor of 'scale', and will be removed in a future release\n", " warnings.warn(msg, FutureWarning)\n", "/home/reves/plume-asr/.direnv/python-3.8.10/lib/python3.8/site-packages/pyannote/audio/features/pretrained.py:156: UserWarning: Model was trained with 4s chunks and is applied on 2s chunks. This might lead to sub-optimal results.\n", " warnings.warn(msg)\n", "Using cache found in /home/reves/.cache/torch/hub/pyannote_pyannote-audio_master\n" ] } ], "source": [ "#pipeline = torch.hub.load('pyannote/pyannote-audio', 'dia_ami')\n", "pipeline = torch.hub.load('pyannote/pyannote-audio', 'dia')" ] }, { "cell_type": "code", "execution_count": 28, "id": "5f69fda5-d94d-4c6f-854d-fd2788ff5bc5", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPU times: user 3.94 s, sys: 179 ms, total: 4.12 s\n", "Wall time: 4.12 s\n" ] } ], "source": [ "%time diarization = pipeline({'audio': '/home/reves/test-dt.wav'})" ] }, { "cell_type": "code", "execution_count": null, "id": "93eb8203-af2f-4905-90ec-7e667200e647", "metadata": {}, "outputs": [], "source": [ "for turn, _, speaker in diarization.itertracks(yield_label=True):\n", " print(f'Speaker \"{speaker}\" speaks between t={turn.start:.1f}s and t={turn.end:.1f}s.')" ] }, { "cell_type": "code", "execution_count": null, "id": "bc0075a9-d089-46a9-bf0c-47ff4a158d8f", "metadata": {}, "outputs": [], "source": [ "from ipywidgets import Audio" ] }, { "cell_type": "code", "execution_count": null, "id": "efdd69fb-06f3-4eee-b167-a73496ebbdca", "metadata": { "tags": [] }, "outputs": [], "source": [ "Audio(value=open('/home/reves/test-dt.wav','rb').read(),format=\"wav\")\n", "# test = Audio.from_file('/home/reves/test-dt.wav', autoplay=False)\n", "# test.play()" ] }, { "cell_type": "code", "execution_count": 3, "id": "9af87675-eade-4b5b-aa22-8b877202102a", "metadata": {}, "outputs": [], "source": [ "from plume.utils.transcribe import chunk_transcribe_meta_gen, transcribe_rpyc_gen\n", "base_transcriber, base_prep = transcribe_rpyc_gen()\n", "transcriber, prep = chunk_transcribe_meta_gen(\n", " base_transcriber, base_prep, method=\"chunked\")" ] }, { "cell_type": "code", "execution_count": 15, "id": "0fef3f35-7143-49c6-8cd2-862b5d2b7344", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import pydub\n", "audio_file = '/home/reves/test-dt.wav'\n", "aseg = pydub.AudioSegment.from_file(audio_file)\n", "aseg" ] }, { "cell_type": "code", "execution_count": 32, "id": "34cbea05-4c57-4a3c-8832-5677d2486231", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "#Agent[1.2s-7.4s]: வணக்கம் சார் என்ளடைய நன்ுன் நகந்துக்கு சுலப்கப்பட்டி ரெச்சோரும் சல் எ்ன செலவு கன்றதுக்காவர் பா் \n", "#Customer[7.4s-8.5s]: யர ர் \n", "#Agent[8.8s-13.6s]: சரனால பிண்டிக்கல் தலப்பாகட்டி ரெஸ்டோரன்ட்ருந்து ஃபீட்பாக் கலெக்ட் வண்றதுக்காக கால் பண்ணிருக்கோம் ச \n", "#Customer[13.9s-14.7s]: அ்கலு மேடம் \n", "#Agent[15.4s-19.7s]: சர் இந்த கால் வந்து ரெண்டு ண்து மூனு நிமிஷம் நடிக்கும் பேசலாம்வாக செர்ன் தெரிலமா \n", "#Customer[20.2s-22.8s]: இல்ல அவள வேலைப \n", "#Customer[23.3s-24.1s]: சரிாச்சா \n", "#Agent[24.7s-33.2s]: எச்ச ஃபீஸ்பாக் கலெக்ட் பண்றதுக்காக கால் பண்ணிருக்கோம் உங்க பேர் ரமேஷன்லா படேஷன் குவாலிட்டி மட்டு வி்சலி் க பு்பப்பறப்பா் செயப்படு் \n", "#Agent[33.5s-37.8s]: நீங்க டைமன் பணிரந்த் அனுபவம் எப்டி எந்த்க்கரக்்சசி்டங் \n", "#Customer[38.2s-41.2s]: ஆஹஆஹ் நல்லாருக்கேன் மேடம்்ுடி \n", "#Customer[42.0s-45.5s]: நன்காசசாகடன் இந்ல எனக்கு ச்ிப்ணிநான்பகே்் \n", "#Customer[46.1s-46.9s]: ஓகேயவநல்ா் \n", "#Agent[47.4s-56.7s]: இ்தரெஸ்கரண்டுக்கு மொத்தம் ஐந்து மதுப்பெண்கள்ர்கறைசர் ஒன்ணு குறைவானது ஐந்ததிலும் ங்ளுட அனுபவத்து வச்சு எுத்கு நீங்க ஐந்து கைந்து குடுத்திருக்கீங்க இந்த மதிப்பெண்கள் உங்களல குடுக்கப்பட்டதீங்களா \n", "#Customer[58.0s-58.4s]: என்ன மேடம் \n", "#Agent[58.9s-68.1s]: அதாவது நேத்து நீங்க ரேட்டிங்பை்கு பைல் மிச் ரெஸ்ட்ரோன்ஸ்ல ப்கிஙகீங்களா சார் வரேட்டிங் சகம் மித்தநன்றி்ச வ்மேஷன் மித் க \n", "#Customer[68.1s-72.8s]: மேடம்என் நம்ப தரவட ஓர் சி இரங்குத்தம்பாத்துருவான கஷ்சப்பட்டங்க எப்டி பண்ணம் சாப்டுவாங்க \n", "#Customer[73.8s-78.4s]: சாபால் நல்லாருந்து என்ன பேசிும் ல்லா இல்லதாு எதனத்தம்ப தரனா \n", "#Customer[78.6s-81.0s]: சொல்லுாசி \n", "#Agent[82.7s-85.6s]: சோதலை அதிகமாருக்கு நிலங்க \n", "#Customer[86.1s-88.6s]: போ்காொ்சம் வேலை யரக்குன்டா ஈவ்னிங் தூரும் \n", "#Customer[89.6s-90.2s]: உ \n" ] } ], "source": [ "for turn, _, speaker in diarization.itertracks(yield_label=True):\n", " #print(f'Speaker \"{speaker}\" speaks between t={turn.start:.1f}s and t={turn.end:.1f}s.')\n", " speaker_label = \"Agent\" if speaker == \"B\" else \"Customer\"\n", " tscirpt = transcriber(prep(aseg[turn.start*1000:turn.end*1000]))\n", " print(f'#{speaker_label}[{turn.start:.1f}s-{turn.end:.1f}s]: {tscirpt}')" ] }, { "cell_type": "code", "execution_count": null, "id": "f4ea9ee1-cc14-4e00-8433-45d416298af2", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.10" } }, "nbformat": 4, "nbformat_minor": 5 }