Update app.py
Browse files
app.py
CHANGED
|
@@ -42,3 +42,16 @@ predicted_ids = model.generate(input_features)
|
|
| 42 |
transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]
|
| 43 |
print(transcription)
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]
|
| 43 |
print(transcription)
|
| 44 |
|
| 45 |
+
def translate_long_text(text):
|
| 46 |
+
chunks = [text[i:i+400] for i in range(0, len(text), 400)]
|
| 47 |
+
translated_chunks = []
|
| 48 |
+
|
| 49 |
+
for chunk in chunks:
|
| 50 |
+
translated = translator(chunk, max_length=512)[0]['translation_text']
|
| 51 |
+
translated_chunks.append(translated)
|
| 52 |
+
|
| 53 |
+
return " ".join(translated_chunks)
|
| 54 |
+
|
| 55 |
+
long_english_text = "Your long English text here..."
|
| 56 |
+
hindi_translation = translate_long_text(long_english_text)
|
| 57 |
+
|