Spaces:
Runtime error
Runtime error
TenzinGayche
commited on
Commit
•
d6242a6
1
Parent(s):
c2b95a6
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,33 @@ import pyewts
|
|
4 |
|
5 |
converter = pyewts.pyewts()
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
|
9 |
pipe = pipeline(model="spsither/whisper-small-r2-70k-2ep",device='cuda') # change to "your-username/the-name-you-picked"
|
|
|
4 |
|
5 |
converter = pyewts.pyewts()
|
6 |
|
7 |
+
def remove_repeated_words(text):
|
8 |
+
# Tokenize the input text into words
|
9 |
+
words = text.split()
|
10 |
+
|
11 |
+
# Create a dictionary to count word occurrences
|
12 |
+
word_count = {}
|
13 |
+
|
14 |
+
# Create a list to store the final words
|
15 |
+
new_words = []
|
16 |
+
|
17 |
+
for word in words:
|
18 |
+
# Check if the word is in the dictionary
|
19 |
+
if word in word_count:
|
20 |
+
# If it has occurred once before, add it to the list with a count of 2
|
21 |
+
if word_count[word] == 1:
|
22 |
+
new_words.append(word)
|
23 |
+
word_count[word] = 2
|
24 |
+
else:
|
25 |
+
# If it has not occurred before, add it to the dictionary with a count of 1
|
26 |
+
word_count[word] = 1
|
27 |
+
new_words.append(word)
|
28 |
+
|
29 |
+
# Join the modified words back into a string
|
30 |
+
result = ' '.join(new_words)
|
31 |
+
return result
|
32 |
+
|
33 |
+
# Example usage
|
34 |
|
35 |
|
36 |
pipe = pipeline(model="spsither/whisper-small-r2-70k-2ep",device='cuda') # change to "your-username/the-name-you-picked"
|