Record voice in android

Создание собственного Android-диктофона с помощью Kotlin

Мультимедийный фреймворк Android поддерживает запись и воспроизведение аудио. В этой статье я покажу, как разработать простое приложение для звукозаписи, которое будет записывать аудио и сохранять его в локальном хранилище Android-устройства с помощью MediaRecorder из Android SDK.

Вы также узнаете, как запросить разрешения у пользователя в режиме реального времени и как работать с локальным хранилищем Android-устройства.

Создание пользовательского интерфейса

Сперва нам нужно создать интерфейс для звукозаписи. Это простой layout с тремя кнопками, которые будут использоваться для запуска, приостановки/возобновления и остановки записи.

Запрос требуемых разрешений

После создания пользовательского интерфейса мы можем начать использовать MediaRecorder для реализации основной функциональности нашего приложения. Но сначала нам нужно запросить необходимые разрешения для записи аудио и доступа к локальному хранилищу. Cделаем мы это это с помощью нескольких простых строк кода в нашем файле AndroidManifest.xml :

Также нужно проверить, одобрил ли пользователь разрешения, прежде чем мы сможем использовать наш MediaRecorder . Сделаем это в Activity MainActivity.kt :

Примечание: позже эти строки кода будут перемещены в OnClickListener кнопки начала записи аудио, чтобы мы могли убедиться, что MediaRecorder не будет запущен без необходимых разрешений.

Запись и сохранение аудио

Добавление OnClickListeners

Добавим слушатели к кнопкам, чтобы они реагировали на пользовательские события. Как я упоминал ранее, проверка на наличие необходимых разрешений будет добавлена в OnClickListener кнопки начала записи аудио:

Настройка MediaRecorder

Далее нам нужно указать путь для сохранения аудио и настроить MediaRecorder.

Мы берём путь к корню нашего внешнего хранилища и добавляем в него имя нашей записи и тип файла. После этого мы создаём объект MediaRecorder и определяем источник звука, аудиокодер, формат и файл для записи.

Запись и сохранение аудио

Код, используемый для запуска MediaRecorder , определяется в OnClickListener кнопки начала записи аудио:

Как видите, нужно вызвать функцию prepare , прежде чем мы сможем начать запись. Мы также встраиваем вызов в блок try-catch, чтобы приложение не сломалось при сбое функции prepare .

OnClickListeners кнопки остановки записи очень похож на код выше.

Здесь мы проверяем, работает ли в данный момент MediaRecorder , прежде чем мы остановим запись, потому что наше приложение сломается, если метод stop будет вызван, в то время как MediaRecorder не будет запущен. После этого мы меняем переменную состояния на false , чтобы пользователь не мог снова нажать кнопку остановки.

Нам осталось определить OnClickListener для кнопки приостановки/возобновления.

В этих двух методах мы проверяем, работает ли MediaRecorder . Если работает, мы приостановим запись и изменим текст кнопки для возобновления. При повторном нажатии запись возобновится.

Наконец, мы можем записать аудио и прослушать его, открыв файл recording.mp3 , который будет сохранён в нашем локальном хранилище. Просто откройте проводник файлов и сделайте поиск по имени файла recording.mp3 .

Исходный код

Вот полный исходный код нашего приложения:

Заключение

Теперь вы знаете, как работает MediaRecorder , как запрашивать разрешения в режиме реального времени и почему это важно делать. Вы также узнали о локальном хранилище вашего устройства Android и о том, как хранить в нём данные.

Более сложная версия этого приложения, в которой есть некоторые дополнительные функции, такие как воспроизведение ваших записей с помощью MediaPlayer , доступна на Github.

Источник

Here’s how to record phone calls on your Android phone

There might be times you need to record a call, like when you’re on an important work call with someone, and recording it is easier than trying to remember all the details later. Although Android devices don’t have the native ability to do so, there are a few apps in the Google Play Store that can do the job — but not all of them will give the best results.

It’s vital to remember that both the federal and state government have laws in place for recording phone calls, so always ensure you have consent before proceeding. Once you have the other party’s authorization to record your call, our handy guide will show you how to record a phone call in Android and help you figure out which apps are worth your time. Are you an iPhone user? Check out our guide on how to record phone calls with an iPhone.

Читайте также:  Выбираем звонилку для андроид

Editor’s Note: There are federal and state laws pertaining to the recording of phone calls. As a general rule of thumb, though, you shouldn’t run into any legal trouble if you capture both parties verbally consenting to the recording. Some states require that only one party consent; however, check your state or local laws if you need further clarification.

Recording calls with Google Voice

Many Android users have the Google Voice app installed on their phone, which makes it easy to record phone calls using a Google Voice account. Not only that, but the app allows you to record your calls for free. Well, at least some of the calls. If you opt for Google Voice, you can only record incoming calls.

First, you need a Google Voice account. If you don’t have one, head to the Google Voice website and follow the on-screen instructions. Then, once your account is set up, you need to enable recording on your account, which is relatively easy to do.

Step 1: Navigate to the Google Voice homepage.

Step 2: Click the three vertical dots more menu located on the left and select Settings from the menu.

Step 3: Scroll to the Calls section and turn on Incoming call options by using the slider on the right.

Once done, you will be able to record incoming calls by simply hitting the “4” button on your keypad. When you press “4,” you and the person you’re talking with will hear a message saying that the recording is underway. Press “4” again, and the recording will stop and automatically save to your inbox. To access your recordings in the Voice app, head to the Menu and tap the Voicemail tab.

Google Voice app

You can also do this by using the Google Voice app. Click the hamburger menu located at the top right-hand corner and go to Settings. Under Calls, turn on Incoming Call Options.

Recording calls with a third-party app

There are many apps out there designed for recording calls on your Android phone, though some of them work better than others. We tested a few of them to see how they worked, but before diving into our suggestions, there is something to keep in mind. Most of these apps rely solely on your microphone to record both incoming and outgoing audio, which means calls that aren’t recorded while on speakerphone will be a little quiet. That said, here are a couple of the better recording apps we’ve come across.

Call Recorder S9 – Automatic Call Recorder Pro

Perhaps the best call recording app around is Automatic Call Recorder Pro, largely because of how well-made the interface is. Thankfully, it doesn’t just look good — it works pretty well, too. The app provides a host of customizable settings, allowing you to tweak the audio quality and set the app to record every call automatically. Another cool feature is “shake to record,” which does exactly what you might think. If you want to record a call, simply shake your phone. You can also set the app to save recordings to various cloud services, such as Google Drive and Dropbox.

Call Recorder – ACR

Another good call recording app in the Google Play Store right now is ACR. There are freemium and premium versions of the app; the latter costs $4 and gets rid of ads. The app is straightforward and looks good. It automatically records and saves calls based on a phone number and lists them in an organized way. In addition to that, the formats of recordings can range from M4As, MP3s, WAVs, and MP4s, among others.

The app also deletes old recordings automatically, but if you don’t want that to happen, you can mark a recording as important. Best of all, if you don’t wish to record calls from a particular number, you can exclude it from recording. You can also protect recordings with a password so nobody else can access them. If you want to upload your recordings to a cloud service, ACR is compatible with popular options such as Google Drive, Dropbox, WebDAV, and OneDrive, among others.

Читайте также:  Тема symbian для андроид

One final thing to keep in mind is that this app doesn’t record Wi-Fi or VoIP calls – only cellular ones. That means that if you use the Google Fi network, which makes calls over Wi-Fi, you need to manually disable Wi-Fi to record the call.

Recording calls with an external recorder

The last method to record a phone conversation can be overcomplicated and expensive. Rather than using an app, you can buy a separate phone recorder — some plug it into your phone’s 3.5mm headphone jack, but most use Bluetooth to connect to your phone. There are also call recording headsets that connect via Bluetooth, like the Waytronic Mobile Call Recording Headset, which will set you back $49 on Amazon.

We’d also recommend the RecorderGear PR200 . This recorder is easy to use, connects to your phone via Bluetooth, and has a built-in speaker, so you can listen to recorded calls directly from the device — and it’s available for $109 from Amazon. True, it’s a bit more expensive than the apps we mentioned earlier, but overall you are spending money for a more user-friendly and consistently more dependable option — great if you regularly record calls.

At the end of the day, look to go for the method that coincides with the quality level you’re seeking from your phone recordings and the amount of money you’re OK with spending to acquire those results.

Источник

How to Record Calls on Your Android Phone

Have an important phone call coming up and want to save it to reference later? You can record both incoming and outgoing calls on your Android phone with the right app.

Want to record phone calls on your Android phone? Google’s mobile OS doesn’t come with a built-in voice recorder, but there are other options. You can use an external recorder or Google Voice, but several third-party apps will allow you to record all phone calls—incoming and outgoing—under the right conditions.

Android Limitations

Those conditions vary. In Android 9.0 Pie, Google added limitations that prevent many apps from recording your phone conversations. The apps may seem to work, but when you play the recording, there’s only silence. In my testing, however, the apps I tested recorded the conversations on my Android 9 phones but not on my Google Pixel phone with Android 10.

Some people have found workarounds to Google’s block, such as changing the audio source or format, turning the speaker volume as loud as possible, recording manually instead of automatically, and even rooting their phones. Also, certain apps may work on specific phones and not on others. So your mileage may vary compared with mine.

Rumors have been floating that Google will add a call-recording feature in a future flavor of Android. But until then, you’ll have to rely on third-party apps compatible with your version of Android.

Meanwhile, because of privacy issues, Google no longer allows calling apps to access the call log to identify the caller. That means each call you record through an app shows up as coming from an unknown caller, even if the caller is in your contact list. In this case, your best option is to rename the recording if the app will let you or store the recording elsewhere as an MP3 file, where you can then rename the file to identify the caller or conversation.

Finally, let’s discuss the elephant in the room, namely is it legal to record a phone call, especially if you don’t ask the other person for permission? The answer to that question depends on where you live. US federal and most state laws allow phone recording if just one party (and yes, that can be you) gives it the okay. Some states, however, require both parties to give permission to be recorded. Other countries have their own laws, of course. To fully cover yourself legally, ask the other person for permission before recording the call.

Okay, now let’s check out some apps for recording your Android phone conversations.

Google Voice

With Google Voice, you choose a dedicated phone number through which incoming calls are routed to your mobile phone. After you set up your phone number and your Google Voice account, tap the app’s hamburger icon in the upper-left corner. Tap the Settings command. Swipe down the screen and turn on the «Incoming call options» to enable call recording. The limitation here is that you can only record incoming calls.

Читайте также:  Гугл расходует батарею андроид

After you answer a call, press the number 4 on the keypad to record the conversation. A message announces that the call is being recorded, so be sure to get the other person’s permission beforehand. To stop the recording, press 4 on the keypad again. The recording is saved to your inbox, where you can listen to it or download it to your computer.

Call Recorder

Call Recorder from BACA Soft is simple to use as it can automatically record your phone calls. Open the app to check it out. The home screen offers four different categories for storing your call recordings—All, Outgoing, Incoming, and Important.

The app’s settings menu allows you to enable or disable Call Recorder to automatically record all calls, outgoing calls, or incoming calls. You can exclude specific phone numbers from recording, tell the app to prompt for a PIN when you open it, and change the file type for the audio recording.

To record an outgoing call, simply call the other party as you normally would. If you set up the app to automatically record incoming calls, you won’t have to do anything for them either. After the call is completed, open Call Recorder to view and play phone call recordings. You can then tag calls as important, delete them, or share them via email or social media.

At the home screen, you can tap the three-dot icon to delete a call, share it, view details on it, add it to the excluded section, or call the number. The free version of Call Recorder saddles you with ads. To escape them, you’ll have to shell out $3.99 for the pro edition.

In my testing, Call Recorder worked fine on Android 9. But on Android 10, the recordings were silent due to the limitations imposed by Google.

Automatic Call Recorder

Automatic Call Recorder from Appliqato is a simple but effective recording app. Before recording anything, it’s best to configure the app’s settings first in the Settings menu. Here, you can enable or disable the option to automatically record each incoming and outgoing call. You can also opt to record only certain contacts and ignore others.

Remember to choose an audio format for your recordings. After recording, the files can be sent to a service like Dropbox or Google Drive, if you set it up. There is also an option to turn on recording if you shake your phone.

If you leave automatic recording on by default, just make or receive a phone call, and the recording begins. After the call ends, open Automatic Call Recorder to view the recording. From the options screen, you can save the call as an audio file to your phone, add call notes, delete the recording, or share it via email, social media, and other services.

The free version of Automatic Call Recorder splashes ads across the screen. For $6.99, the Pro version puts the kibosh on the ads and kicks in other features. While Automatic Call Recorder worked well on Android 9, the recording on Android 10 was silent.

Call Recorder

Call Recorder from Lovekara is a simple but useful call recorder with a clean and stylish interface. Fire up the app, tap the three-dot icon and select Settings.

Here, you can set Call Recorder to automatically or manually record calls. Other options allow you to set the file location, change the recording source, and record automatically from your phone’s speaker.

Now, if you set the app to automatic, it will record incoming and outgoing calls from start to finish. Tap the recording when it appears onscreen to view it in the app. From the recording screen, you can play the file, save it to your phone, share it via email or other services, and delete the recording.

The app is free but does throw ads your way. This app also worked smoothly on Android 9 but delivered silent recordings on Android 10.

Источник

Оцените статью