Spaces:
Running
Running
Create app-BACKUP-16-04-2024.py
Browse files- app-BACKUP-16-04-2024.py +309 -0
app-BACKUP-16-04-2024.py
ADDED
@@ -0,0 +1,309 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# JBHF/VERTAAL-APP-EAGLE-SHELTER/app.py - 16-04-2024, 14u00m CET
|
2 |
+
# WERKT AL: DE OPGENOMEN AUDIO MBV DEZE APP, audio.wav, HOEFT NIET PERSÉ GEPERSISTEERD TE WORDEN !!!!!!
|
3 |
+
|
4 |
+
# https://github.com/theevann/streamlit-audiorecorder
|
5 |
+
# An audio Recorder for streamlit
|
6 |
+
#
|
7 |
+
# Description
|
8 |
+
# Audio recorder component for streamlit.
|
9 |
+
# It creates a button to start the recording and takes three arguments:
|
10 |
+
# the start button text, the stop button text, and the pause button text.
|
11 |
+
# If the pause button text is not specified, the pause button is not displayed.
|
12 |
+
#
|
13 |
+
# Parameters
|
14 |
+
# The signature of the component is:
|
15 |
+
# audiorecorder(start_prompt="Start recording", stop_prompt="Stop recording", pause_prompt="", key=None):
|
16 |
+
# The prompt parameters are self-explanatory, and the optional key parameter is used internally by streamlit
|
17 |
+
# to properly distinguish multiple audiorecorders on the page.
|
18 |
+
#
|
19 |
+
# Return value
|
20 |
+
# The component's return value is a pydub AudioSegment.
|
21 |
+
#
|
22 |
+
# All AudioSegment methods are available, in particular you can:
|
23 |
+
# - Play the audio in the frontend with st.audio(audio.export().read())
|
24 |
+
# - Save the audio to a file with audio.export("audio.wav", format="wav")
|
25 |
+
# JB: Waarom zie ik in mijn HF Spaces omgeving de file "audio.wav" niet terug ?
|
26 |
+
# JB: 08-04-2024 - Mogelijk is caching al voldoende (anders file persistence)#
|
27 |
+
# Zie hiervoor:
|
28 |
+
#
|
29 |
+
# CACHING:
|
30 |
+
# ========
|
31 |
+
# STREAMLIT - Caching overview - Streamlit Docs - 07-04-2024 !!!!!
|
32 |
+
# https://docs.streamlit.io/develop/concepts/architecture/caching
|
33 |
+
#
|
34 |
+
# EVERNOTE :
|
35 |
+
# https://www.evernote.com/shard/s313/nl/41973486/31880952-8bd9-41ef-8047-ca844143e833/
|
36 |
+
# STREAMLIT - Caching overview - Streamlit Docs - 07-04-2024 !!!!!
|
37 |
+
#
|
38 |
+
# 08-04-2024
|
39 |
+
#
|
40 |
+
# EN
|
41 |
+
#
|
42 |
+
# PERSISTENCE:
|
43 |
+
# ============
|
44 |
+
# HF SPACES STREAMLIT APPS - GET PASSWORDS AND ACCESS TOKENS FROM HF ENVIRONMENT ! - PERSISTENT STORAGE ON HF SPACES ! - EAGLE SHELTER VERTAAL APP ETC ! - app.py · julien-c/persistent-data at main - 20-03-2024 !!!!! !!!!! !!!!!
|
45 |
+
# https://huggingface.co/spaces/julien-c/persistent-data/blob/main/app.py
|
46 |
+
#
|
47 |
+
# ——->
|
48 |
+
#
|
49 |
+
# DUPLICATED TO:
|
50 |
+
# https://huggingface.co/spaces/JBHF/persistent-data?logs=container
|
51 |
+
#
|
52 |
+
# EVERNOTE :
|
53 |
+
# https://www.evernote.com/shard/s313/nl/41973486/1b07098e-3376-4316-abb3-b3d0996ebf03/
|
54 |
+
# HF SPACES STREAMLIT APPS - GET PASSWORDS AND ACCESS TOKENS FROM HF ENVIRONMENT ! - PERSISTENT STORAGE ON HF SPACES ! - EAGLE SHELTER VERTAAL APP ETC ! - app.py · julien-c/persistent-data at main - 20-03-2024 !!!!! !!!!! !!!!!
|
55 |
+
#
|
56 |
+
# 08-04-2024
|
57 |
+
#
|
58 |
+
|
59 |
+
import os
|
60 |
+
import streamlit as st
|
61 |
+
|
62 |
+
###########################################################################################################
|
63 |
+
# VERTALING
|
64 |
+
# DAADWERKELIJK MET MIC OPGENOMEN EN GETRANSCRIBEERD STUKJE OEKRAÍENSE TEKST TER TEST
|
65 |
+
# OM HIERONDER NAAR NEDERLANDS TE VERTALEN MBV LLM MIXTRAL-8x7b-GROQ! :
|
66 |
+
# text_to_transcribe:
|
67 |
+
# князем Данилом Романовичем біля Звенигорода і названий на честь його сина Лева Сьогодні Львів має площу 155 квадратних кілометрів з безліччю громадських будинків, кафе, магазинів
|
68 |
+
# ...
|
69 |
+
|
70 |
+
# TEXTS FROM UKRAIN TO TRANSLATE:
|
71 |
+
# 1 - Short text from https://youtu.be/1_vO60OkkrY?list=PLeeQI3aTmCn9Lu9mgSCmmc-KkGI95-Ie6 :
|
72 |
+
text_to_transcribe = """князем Данилом Романовичем біля Звенигорода і названий на честь його сина Лева Сьогодні Львів має площу 155 квадратних кілометрів з безліччю громадських будинків, кафе, магазинів"""
|
73 |
+
#
|
74 |
+
# 2 - complete, long text from https://youtu.be/1_vO60OkkrY?list=PLeeQI3aTmCn9Lu9mgSCmmc-KkGI95-Ie6 :
|
75 |
+
text_to_transcribe = """
|
76 |
+
Львів – одне з моїх найулюбленіших міст України. Я вже відвідувала це місто п’ять разів, але хочу повертатися туди знову і знову. Львів – це історична столиця Галичини і Західної України. Це великий культурний, політичний і релігійний центр України.
|
77 |
+
Львів був заснований у середині XIII ст. князем Данилом Романовичем біля Звенигорода і названий на честь його сина, Лева. Сьогодні Львів має площу 155 км. кв. Найбільш виразна частина Львова включає проспект Шевченка і Городецьку вулицю, з безліччю громадських будинків, готелів, кафе, магазинів і банків у стилі ХІХ-ХХ ст.
|
78 |
+
Львів – дивовижне місто, яке наскрізь просякнуте п’янким ароматом кави і шоколаду. Світ візит я починаю із серця Львова – Площа ринок, потім я підіймаюся на Ратушу. Я люблю відвідувати заклади, які стали візитівкою міста такі як: Копальня кави, Майстерня шоколаду, Гасова Лямпа, Дім Легенд. Львів — єдине в Україні місто, у якому збереглися архітектурні споруди часів Ренесансу. Найбільш яскравими прикладами цього стилю служать церква Успіння і каплиця Трьох Святих.
|
79 |
+
Основні пам'ятники міста — пам'ятник А. Міцкевичу, І. Франку, В. Стефанику, С. Бандері. Екскурсія середньовічними замками також не залишає нікого байдужим.
|
80 |
+
Неможливо передати словами всю красу і велич Львова, треба бачити це самостійно. Це старовинне місто, яке зачаровує своїми традиціями, красою та шармом.
|
81 |
+
"""
|
82 |
+
st.write("text_to_transcribe: ", text_to_transcribe)
|
83 |
+
|
84 |
+
# Groq in Langchain
|
85 |
+
# Groq is even compatible with LangChain. To begin using Groq in LangChain, download the library:
|
86 |
+
# !pip install langchain-groq
|
87 |
+
# The above will install the Groq library for LangChain compatibility. Now let’s try it out in code:
|
88 |
+
|
89 |
+
# Import the necessary libraries.
|
90 |
+
from langchain_core.prompts import ChatPromptTemplate
|
91 |
+
from langchain_groq import ChatGroq
|
92 |
+
|
93 |
+
groq_api_key = os.environ['GROQ_API_KEY']
|
94 |
+
# groq_api_key = "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" # os.environ['GROQ_API_KEY']
|
95 |
+
# groq_api_key = "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" # JB OK 24-03-2024
|
96 |
+
st.write("groq_api_key: ", groq_api_key)
|
97 |
+
|
98 |
+
# Initialize a ChatGroq object with a temperature of 0 and the "mixtral-8x7b-32768" model.
|
99 |
+
llm = ChatGroq(temperature=0, model_name="mixtral-8x7b-32768")
|
100 |
+
# The above code does the following:
|
101 |
+
# -Creates a new ChatGroq object named llm
|
102 |
+
# -Sets the temperature parameter to 0, indicating that the responses should be more predictable
|
103 |
+
# -Sets the model_name parameter to “mixtral-8x7b-32768“, specifying the language model to use
|
104 |
+
|
105 |
+
# Define the system message introducing the AI assistant's capabilities.
|
106 |
+
# system = "You are an expert Coding Assistant."
|
107 |
+
# system = "You are an expert translation Assistant, proficient in all languages."
|
108 |
+
system = """
|
109 |
+
You are an expert translation Assistant, proficient in all languages.
|
110 |
+
You only deliver the translation as output, nothing else. No comments or explanations.
|
111 |
+
"""
|
112 |
+
|
113 |
+
# Define a placeholder for the user's input.
|
114 |
+
human = "{text}"
|
115 |
+
|
116 |
+
# Create a chat prompt consisting of the system and human messages.
|
117 |
+
prompt = ChatPromptTemplate.from_messages([("system", system), ("human", human)])
|
118 |
+
|
119 |
+
# Invoke the chat chain with the user's input.
|
120 |
+
chain = prompt | llm
|
121 |
+
|
122 |
+
# response = chain.invoke({"text": "Write a simple code to generate Fibonacci numbers in Rust?"}) # ORIGINAL
|
123 |
+
# response = chain.invoke({"text": "TRANSLATE THE FOLLOWING TEXT INTO ENGLISH" + text_to_transcribe}) # JB TRANSLATE TO ENGLISH
|
124 |
+
response = chain.invoke({"text": \
|
125 |
+
"""Translate the following text into correct Dutch language
|
126 |
+
and do not use any other language for your response whatsover or you will get severly punished.
|
127 |
+
Do not translate names of places, towns and other geographical names.
|
128 |
+
Do not translate names of people.
|
129 |
+
Translate the text into correct, impeccable English, and then translate that English text into perfect Dutch in a second step.
|
130 |
+
""" + text_to_transcribe}) # JB TRANSLATE TO DUTCH
|
131 |
+
|
132 |
+
|
133 |
+
text_to_transcribe = response.content
|
134 |
+
|
135 |
+
response = chain.invoke({"text": \
|
136 |
+
"""Translate the following text into correct Dutch language
|
137 |
+
and do not use any other language for your response whatsover or you will get severly punished.
|
138 |
+
Do not translate names of places, towns and other geographical names.
|
139 |
+
Do not translate names of people.
|
140 |
+
Translate the text into correct, impeccable perfect Dutch.
|
141 |
+
""" + text_to_transcribe}) # JB TRANSLATE TO DUTCH
|
142 |
+
|
143 |
+
# Print the Response.
|
144 |
+
# print(response.content)
|
145 |
+
st.write(response.content)
|
146 |
+
|
147 |
+
# - The code generates a Chat Prompt using the ChatPromptTemplate class.
|
148 |
+
# - The prompt comprises two messages: one from the “system” (the AI assistant) and one from the “human” (the user).
|
149 |
+
# - The system message presents the AI assistant as an expert Coding Assistant.
|
150 |
+
# - The human message serves as a placeholder for the user’s input.
|
151 |
+
# - The llm method invokes the llm chain to produce a response based on the provided Prompt and the user’s input.
|
152 |
+
|
153 |
+
|
154 |
+
|
155 |
+
###########################################################################################################
|
156 |
+
|
157 |
+
|
158 |
+
###########################################################################################################
|
159 |
+
#
|
160 |
+
# Installation:
|
161 |
+
# pip install streamlit-audiorecorder
|
162 |
+
# Note: This package uses ffmpeg, so it should be installed for this audiorecorder to work properly.
|
163 |
+
#
|
164 |
+
# On ubuntu/debian: sudo apt update && sudo apt install ffmpeg
|
165 |
+
# On mac: brew install ffmpeg
|
166 |
+
|
167 |
+
import streamlit as st
|
168 |
+
from audiorecorder import audiorecorder
|
169 |
+
|
170 |
+
st.title("Audio Recorder")
|
171 |
+
# audiorecorder(start_prompt="Start recording", stop_prompt="Stop recording", pause_prompt="", key=None):
|
172 |
+
audio = audiorecorder("Click to record", "Click to stop recording", "Click to pause recording")
|
173 |
+
|
174 |
+
|
175 |
+
# JB:
|
176 |
+
# https://docs.streamlit.io/develop/concepts/architecture/caching
|
177 |
+
# @st.cache_data
|
178 |
+
# @st.cache_resource # 👈 Add the caching decorator WERKT WEL,
|
179 |
+
# MAAR HOUDT DAN "audio.wav" FILE VAST BINNEN DE HUIDIGE SESSIE
|
180 |
+
# EN ALS JE DAN EEN NIEUWE OPNAME MAAKT, BLIJFT DE OUDE "audio.wav" BESTAAN
|
181 |
+
# EN WORDT DAN NIET MET DE NIEUWE OPNAME OVERSCHREVEN !
|
182 |
+
#@st.cache_resource # 👈 Add the caching decorator
|
183 |
+
def audio_export(audio_wav_file, format):
|
184 |
+
# audio.export("audio.wav", format="wav") # ORIGINAL
|
185 |
+
audio.export(audio_wav_file, format=format)
|
186 |
+
|
187 |
+
if len(audio) > 0:
|
188 |
+
# To play audio in frontend:
|
189 |
+
st.audio(audio.export().read())
|
190 |
+
|
191 |
+
# To save audio to a file, use pydub export method:
|
192 |
+
# https://docs.streamlit.io/develop/concepts/architecture/caching
|
193 |
+
# @st.cache_data
|
194 |
+
# @st.cache_data
|
195 |
+
# audio.export("audio.wav", format="wav") # ORIGINAL
|
196 |
+
audio_export("audio.wav", format="wav") # JB 08-04-2024
|
197 |
+
|
198 |
+
# To get audio properties, use pydub AudioSegment properties:
|
199 |
+
st.write(f"Frame rate: {audio.frame_rate}, Frame width: {audio.frame_width}, Duration: {audio.duration_seconds} seconds")
|
200 |
+
|
201 |
+
|
202 |
+
st.button("Rerun")
|
203 |
+
###########################################################################################################
|
204 |
+
|
205 |
+
|
206 |
+
###########################################################################################################
|
207 |
+
# TEST
|
208 |
+
# ZIE:
|
209 |
+
# infer_faster_whisper_large_v2 (CPU VERSIE !) 08-04-2024-COLAB-CPU-PYTHON3-tvscitechtalk.ipynb
|
210 |
+
# https://colab.research.google.com/drive/1EreiFx825oIrR2P43XSXjHXx01EWi6ZH#scrollTo=vuLjbPxexPDj&uniqifier=5
|
211 |
+
|
212 |
+
from faster_whisper import WhisperModel
|
213 |
+
|
214 |
+
model_size = "large-v2"
|
215 |
+
|
216 |
+
# Run on GPU with FP16
|
217 |
+
# model = WhisperModel(model_size, device="cuda", compute_type="float16") # ORIGINAL, DRAAIT OP COLAB T4 GPU OK
|
218 |
+
|
219 |
+
# TEST: Run on CPU
|
220 |
+
# model = WhisperModel(model_size, device="cpu", compute_type="float16") # JB, DRAAIT OP COLAB CPU OK ?
|
221 |
+
# ValueError: Requested float16 compute type, but the target device or backend do not support efficient float16 computation.
|
222 |
+
#
|
223 |
+
# st.write("Loading the WhisperModel: model = WhisperModel(model_size, device=\"cpu\")")
|
224 |
+
# model = WhisperModel(model_size, device="cpu") # , compute_type="float16") # JB, DRAAIT OP COLAB CPU OK: JA; HF SPACES STREAMLIT FREE TIER: JB OK !
|
225 |
+
# JB: Dit gebruikt mijn HF Token !
|
226 |
+
# st.write("Ready Loading the WhisperModel: model = WhisperModel(model_size, device=\"cpu\")")
|
227 |
+
|
228 |
+
st.write("Loading the WhisperModel: model = WhisperModel(model_size, device=\"cpu\", compute_type=\"int8\")")
|
229 |
+
model = WhisperModel(model_size, device="cpu", compute_type="int8") # , compute_type="float16") # JB
|
230 |
+
# JB: Dit gebruikt mijn HF Token !
|
231 |
+
# st.write("Ready Loading the WhisperModel: model = WhisperModel(model_size, device=\"cpu\")")
|
232 |
+
# LOADING OF model = WhisperModel(model_size, device="cpu") TAKES ABOUT 1 MINUTE ON HF SPACES STREAMLIT FREE TIER
|
233 |
+
#
|
234 |
+
st.write("Ready Loading the WhisperModel: model = WhisperModel(model_size, device=\"cpu\", compute_type=\"int8\")")
|
235 |
+
# LOADING OF model = WhisperModel(model_size, device=\"cpu\", compute_type=\"int8\") TAKES ABOUT 33 sec (Na RERUN 1 minute) ON HF SPACES STREAMLIT FREE TIER
|
236 |
+
|
237 |
+
|
238 |
+
# USING:
|
239 |
+
# model = WhisperModel(model_size, device="cpu", compute_type="int8") # JB
|
240 |
+
# segments, info = model.transcribe("sam_altman_lex_podcast_367.flac", beam_size=1)
|
241 |
+
|
242 |
+
# /content/Ukrainian podcast #10 Traveling to Lviv - Подорож до Льова. SLOW UKRAINIAN.mp3
|
243 |
+
# segments, info = model.transcribe("Ukrainian podcast #10 Traveling to Lviv - Подорож до Льова. SLOW UKRAINIAN.mp3", beam_size=1)
|
244 |
+
# TEST:
|
245 |
+
segments, info = model.transcribe("audio.wav", beam_size=1) # DIT WERKT: GEDURENDE DE SESSIE BLIJFT audio.wav FILE BESCHIKBAAR IN DEZE APP !!!!!
|
246 |
+
|
247 |
+
|
248 |
+
# print("Detected language '%s' with probability %f" % (info.language, info.language_probability))
|
249 |
+
st.write("Detected language '%s' with probability %f" % (info.language, info.language_probability))
|
250 |
+
st.write("")
|
251 |
+
st.write("info.all_language_probs : ", info.all_language_probs)
|
252 |
+
st.write("len(info.all_language_probs): ", len(info.all_language_probs))
|
253 |
+
# 99
|
254 |
+
|
255 |
+
st.write("")
|
256 |
+
|
257 |
+
st.write("info: ", info)
|
258 |
+
|
259 |
+
# Ukrainian podcast #10 Traveling to Lviv - Подорож до Льова. SLOW UKRAINIAN.mp3 :
|
260 |
+
st.write("info.duration: ", info.duration)
|
261 |
+
# 233.8249375
|
262 |
+
# time: 3.98 ms (started: 2024-03-15 10:55:15 +00:00)
|
263 |
+
# minutes = int(info.duration / 60)
|
264 |
+
# seconds = info.duration - minutes*60
|
265 |
+
minutes = int(info.duration / 60)
|
266 |
+
seconds = info.duration - minutes*60
|
267 |
+
|
268 |
+
st.write(minutes," minutes and ", seconds, " seconds")
|
269 |
+
|
270 |
+
|
271 |
+
text_to_transcribe = ""
|
272 |
+
for segment in segments:
|
273 |
+
# print("[%.2fs -> %.2fs] %s" % (segment.start, segment.end, segment.text))
|
274 |
+
st.write("[%.2fs -> %.2fs] %s" % (segment.start, segment.end, segment.text))
|
275 |
+
text_to_transcribe = text_to_transcribe + " " + segment.text
|
276 |
+
|
277 |
+
st.write("---------------------------------------------------------------------")
|
278 |
+
|
279 |
+
#text_to_transcribe = ""
|
280 |
+
#st.write("TOTAL TEXT TO TRANSCRIBE:")
|
281 |
+
#for segment in segments:
|
282 |
+
# st.write(segment.text)
|
283 |
+
# text_to_transcribe = text_to_transcribe + " " + segment
|
284 |
+
# # print(segment)
|
285 |
+
|
286 |
+
#st.write("text_to_transcribe: ", text_to_transcribe)
|
287 |
+
# DAADWERKELIJK MET MIC OPGENOMEN EN GETRANSCRIBEERD STUKJE OEKRAÍENSE TEKST TER TEST
|
288 |
+
# OM HIERONDER NAAR NEDERLANDS TE VERTALEN MBV LLM MIXTRAL-8x7b-GROQ! :
|
289 |
+
# text_to_transcribe:
|
290 |
+
# князем Данилом Романовичем біля Звенигорода і названий на честь його сина Лева Сьогодні Львів має площу 155 квадратних кілометрів з безліччю громадських будинків, кафе, магазинів
|
291 |
+
|
292 |
+
###########################################################################################################
|
293 |
+
# VERTALEN NAAR NEDERLANDS VAN DE CONTENT IN text_to_transcribe:
|
294 |
+
# (PROBEER OOK EEN 2 STAPS VERTALING: EERST NAAR ENGELS,
|
295 |
+
# EN DAN DIE ENGELSE TEKST NAAR NEDERLANDS TE VERTALEN.
|
296 |
+
# DOEL: DE VERTALING VAN OEKRAÏENS (VIA ENGELS) NAAR NEDERLANDS TE VERBETEREB.)
|
297 |
+
response = chain.invoke({"text": \
|
298 |
+
"""Translate the following text into correct Dutch language
|
299 |
+
and do not use any other language for your response whatsover or you will get severly punished.
|
300 |
+
Do not translate names of places, towns and other geographical names.
|
301 |
+
Do not translate names of people.
|
302 |
+
Only give the translation and not anything else!
|
303 |
+
No comments, no explanations, only give the translated text!
|
304 |
+
""" + text_to_transcribe}) # JB TRANSLATE TO DUTCH
|
305 |
+
|
306 |
+
# Print the Response.
|
307 |
+
# print(response.content)
|
308 |
+
st.write("ORIGINELE TEKST : ", text_to_transcribe)
|
309 |
+
st.write("NEDERLANDSE VERTALING HIERVAN: ", response.content)
|