Local translation module based on the hugging face transformer
Project description
retico-hftranslate
Local translation module based on the hugging face transformer library.
Example
from retico_core import *
import retico_wav2vecasr
import retico_speechbraintts
import retico_hftranslate
msg = []
def callback(update_msg):
global msg
for x, ut in update_msg:
if ut == UpdateType.ADD:
msg.append(x)
if ut == UpdateType.REVOKE:
msg.remove(x)
txt = ""
committed = False
for x in msg:
txt += x.text + " "
committed = committed or x.committed
print(" " * 80, end="\r")
print(f"{txt}", end="\r")
if committed:
msg = []
print("")
m1 = audio.MicrophoneModule()
m2 = retico_wav2vecasr.Wav2VecASRModule(language="de")
m3 = retico_hftranslate.HFTranslateModule(from_lang="de", to_lang="en")
m5 = retico_speechbraintts.SpeechBrainTTSModule(language="en")
m6 = audio.SpeakerModule(rate=22050)
m4 = debug.CallbackModule(callback)
m1.subscribe(m2)
m2.subscribe(m3)
m3.subscribe(m4)
m3.subscribe(m5)
m5.subscribe(m6)
network.run(m1)
print("Press any key to exit")
input()
network.stop(m1)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file retico-hftranslate-0.1.2.tar.gz
.
File metadata
- Download URL: retico-hftranslate-0.1.2.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 693a8eb5911a2eef85a7cb85f7a5d674d091487dc1bd8d4b1708cea9fed8ceaa |
|
MD5 | 010b1ff66cffffda2b0da516fdc98c82 |
|
BLAKE2b-256 | 92f85f1da207f7eee66078abfaaa39fbd5696a1424b826b2f8a4fdca301357e2 |