Skip to content

Commit 7c0c193

Browse files
convertendo audio curto para texto
1 parent 7f65aed commit 7c0c193

File tree

6 files changed

+45
-3
lines changed

6 files changed

+45
-3
lines changed

.DS_Store

6 KB
Binary file not shown.

SpeechIOS.xcodeproj/project.pbxproj

+10-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
4DD2BA9623230C7800A2DC26 /* us000121.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 4DD2BA9523230C7700A2DC26 /* us000121.mp3 */; };
11+
4DD2BA982323137800A2DC26 /* teste.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 4DD2BA972323137800A2DC26 /* teste.mp3 */; };
1012
923DD4252322EE25006DAE75 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 923DD4242322EE25006DAE75 /* AppDelegate.swift */; };
1113
923DD4272322EE25006DAE75 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 923DD4262322EE25006DAE75 /* ViewController.swift */; };
1214
923DD42A2322EE25006DAE75 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 923DD4282322EE25006DAE75 /* Main.storyboard */; };
@@ -34,6 +36,8 @@
3436
/* End PBXContainerItemProxy section */
3537

3638
/* Begin PBXFileReference section */
39+
4DD2BA9523230C7700A2DC26 /* us000121.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = us000121.mp3; sourceTree = "<group>"; };
40+
4DD2BA972323137800A2DC26 /* teste.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = teste.mp3; sourceTree = "<group>"; };
3741
923DD4212322EE25006DAE75 /* SpeechIOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SpeechIOS.app; sourceTree = BUILT_PRODUCTS_DIR; };
3842
923DD4242322EE25006DAE75 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
3943
923DD4262322EE25006DAE75 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
@@ -101,6 +105,8 @@
101105
923DD4262322EE25006DAE75 /* ViewController.swift */,
102106
923DD4282322EE25006DAE75 /* Main.storyboard */,
103107
923DD42B2322EE26006DAE75 /* Assets.xcassets */,
108+
4DD2BA9523230C7700A2DC26 /* us000121.mp3 */,
109+
4DD2BA972323137800A2DC26 /* teste.mp3 */,
104110
923DD42D2322EE26006DAE75 /* LaunchScreen.storyboard */,
105111
923DD4302322EE26006DAE75 /* Info.plist */,
106112
);
@@ -230,7 +236,9 @@
230236
buildActionMask = 2147483647;
231237
files = (
232238
923DD42F2322EE26006DAE75 /* LaunchScreen.storyboard in Resources */,
239+
4DD2BA982323137800A2DC26 /* teste.mp3 in Resources */,
233240
923DD42C2322EE26006DAE75 /* Assets.xcassets in Resources */,
241+
4DD2BA9623230C7800A2DC26 /* us000121.mp3 in Resources */,
234242
923DD42A2322EE25006DAE75 /* Main.storyboard in Resources */,
235243
);
236244
runOnlyForDeploymentPostprocessing = 0;
@@ -433,7 +441,7 @@
433441
buildSettings = {
434442
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
435443
CODE_SIGN_STYLE = Automatic;
436-
DEVELOPMENT_TEAM = NM36QJ4P82;
444+
DEVELOPMENT_TEAM = GM73VGBYQV;
437445
INFOPLIST_FILE = SpeechIOS/Info.plist;
438446
LD_RUNPATH_SEARCH_PATHS = (
439447
"$(inherited)",
@@ -451,7 +459,7 @@
451459
buildSettings = {
452460
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
453461
CODE_SIGN_STYLE = Automatic;
454-
DEVELOPMENT_TEAM = NM36QJ4P82;
462+
DEVELOPMENT_TEAM = GM73VGBYQV;
455463
INFOPLIST_FILE = SpeechIOS/Info.plist;
456464
LD_RUNPATH_SEARCH_PATHS = (
457465
"$(inherited)",

SpeechIOS/Info.plist

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5+
<key>NSSpeechRecognitionUsageDescription</key>
6+
<string>We need this for go on ... </string>
57
<key>CFBundleDevelopmentRegion</key>
68
<string>$(DEVELOPMENT_LANGUAGE)</string>
79
<key>CFBundleExecutable</key>

SpeechIOS/ViewController.swift

+33-1
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,46 @@
77
//
88

99
import UIKit
10+
import Speech
1011

1112
class ViewController: UIViewController {
1213

1314
override func viewDidLoad() {
1415
super.viewDidLoad()
1516
// Do any additional setup after loading the view.
17+
18+
requestPermissionsForSpeech()
1619
}
1720

18-
21+
func requestPermissionsForSpeech() {
22+
SFSpeechRecognizer.requestAuthorization { (status) in
23+
DispatchQueue.main.async {
24+
if status == .authorized {
25+
print("Autorized")
26+
var url = Bundle.main.url(forResource: "teste", withExtension: "mp3")
27+
// var url = URL.init(fileURLWithPath: "us000121") as? URL
28+
guard let url2 = url else { return }
29+
self.transcribeAudio(url: url2)
30+
} else {
31+
print("Not autorized")
32+
}
33+
}
34+
}
35+
}
36+
37+
func transcribeAudio(url: URL) {
38+
let recognize = SFSpeechRecognizer()
39+
let request = SFSpeechURLRecognitionRequest(url: url)
40+
41+
recognize?.recognitionTask(with: request, resultHandler: { (result, error) in
42+
guard let result = result else {
43+
print("No this time")
44+
return }
45+
if result.isFinal {
46+
47+
print(result.bestTranscription.formattedString)
48+
}
49+
})
50+
}
1951
}
2052

SpeechIOS/teste.mp3

36.1 KB
Binary file not shown.

SpeechIOS/us000121.mp3

3.21 MB
Binary file not shown.

0 commit comments

Comments
 (0)